Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/09/2014, 17:23
Avatar de odek
odek
 
Fecha de Ingreso: julio-2011
Ubicación: México
Mensajes: 55
Antigüedad: 12 años, 10 meses
Puntos: 1
Problemas de cierre de sesión

Porque no me redirige este código, cuando escribo la pagina en el navegador aparece en blanco pero no cambia a index.php.

Código PHP:
Ver original
  1. <?php
  2. if(isset ($_SESSION['usuario'])) {
  3. header('Location: ../index.php');
  4.         }
  5. elseif (isset ($_SESSION['contrasena'] )) {
  6. header('Location: ../index.php');
  7. }
  8. else {
  9. $enlace[1]="inicio1.php";
  10. $enlace[2]="inicio2.php";
  11. $enlace[3]="inicio3.php";
  12.  
  13. $total_enlaces=1;
  14. while ( !empty($enlace[$total_enlaces+1]) ) {
  15.         $total_enlaces++;
  16. }
  17.  
  18. $aleatorio=rand(1,$total_enlaces);
  19.  
  20. /*echo '
  21.         <html>
  22.         <head>
  23.         <meta http-equiv="refresh" content="0;url=... '.$enlace[$aleatorio].'">
  24.         </head>
  25.         </html>
  26.         ';*/
  27. }
  28.  
  29. ?>



Si a ese código agrego un cierre de sesión por tiempo tampoco lo cierra

Código PHP:
Ver original
  1. <?php
  2.  $inactivo = 600;
  3.     if (isset($_SESSION["timeout"])) {
  4.         $tiempoSession = time() - $_SESSION["timeout"];
  5.         if ($tiempoSession > $inactivo) {
  6.             session_destroy();
  7.             header("Location: ../index.php");
  8.         }
  9.     }
  10.     $_SESSION["timeout"] = time();
  11. ?>



Es correcto este cierre de cookies

Código PHP:
Ver original
  1. <?php
  2. $_SESSION = array();
  3. if (ini_get("session.use_cookies"))
  4. {
  5.   setcookie(session_name(), '', time() - 42000,
  6.       $params["path"], $params["domain"],
  7.       $params["secure"], $params["httponly"]);
  8. }
  9. ?>
__________________
Mi life in pixel -_-