<?php class salir { public function out() { session_start(); session_destroy(); header('location:../index.php'); } } $miSalir = new salir(); $miSalir->out();
private function confirma() { echo ' <script language="JavaScript"> if (!confirm("Esta a punto de cerrar su sesion, esta seguro ?")){ window.location = "javascript:history.back(-1)"; }else{ window.location = "logout.php?conf=s"; } </script>'; } public function exe_salir() { if ($this->accion == "s") { $this->destruye_cookies(); $var_validacion = $this->valida(); if ($var_validacion == true) { echo '<script language="JavaScript"> alert("Ha salido exitosamente"); window.location = "../pages/login.php"; </script>'; } else { print_r($var_validacion); echo '<script language="JavaScript"> alert("Ha ocurrido un error, no se puede cerrar la sesión."); window.location = "javascript:history.back(-1)"; </script>'; } } else { $this->confirma(); } } } //-------------------------------------------------------------------------------------------------------- $salir = new salir($conf = $_GET['conf']); $salir->exe_salir(); //--------------------------------------------------------------------------------------------------------