Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/08/2010, 21:03
Avatar de carlos_belisario
carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: Control de Expiracion de Sesiones

bueno yo trabajo el logeuo con sesiones tambien y en codigos q fui viendo me invente esta funcion para sacar al usuario al tiempo determinado si te sirve usala o modificala o mejorala a tu manera suerte
Código PHP:
Ver original
  1. <?php
  2.  
  3.  
  4. function seguridad($tiempo_inactivo=5){
  5.  
  6.     if(is_numeric($tiempo_inactivo)){
  7.  
  8.         ### verificamos q el usuario este auntentificado ###       
  9.  
  10.         if($_SESSION['user_auten']=="usuario_ingresado"){
  11.  
  12.             $fecha=date("H:i:s d-m-Y ",mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")));
  13.  
  14.             if($_SESSION["fecha_com"]==""){
  15.  
  16.                 $fecha_com=date("H:i:s d-m-Y ",mktime(date("H"),date("i")+$tiempo_inactivo,date("s"),date("m"),date("d"),date("Y")));
  17.  
  18.                 $_SESSION["fecha_com"]=$fecha_com;
  19.  
  20.             }
  21.  
  22.             else{
  23.  
  24.                 if($fecha>$_SESSION["fecha_com"]){
  25.  
  26.                     session_destroy();
  27.  
  28.                     header("location:index.php");#pagina a donde redireccionara si esta inactivo
  29.  
  30.                     exit;
  31.  
  32.                 }
  33.  
  34.                 else{                  
  35.  
  36.                     $fecha_com=date("H:i:s d-m-Y ",mktime(date("H"),date("i")+$tiempo_inactivo,date("s"),date("m"),date("d"),date("Y")));
  37.  
  38.                     $_SESSION["fecha_com"]=$fecha_com;
  39.  
  40.                 }                  
  41.  
  42.             }          
  43.  
  44.         }
  45.  
  46.         else{
  47.  
  48.             header("location:index.php");#pagina a donde redireccionara sino esta auntentificado
  49.  
  50.             exit;
  51.  
  52.         }          
  53.  
  54.     }
  55.     else{
  56.         echo "el parametro debe de ser numerico";
  57.     }          
  58.  
  59. }
  60.  
  61. seguridad();       
  62.  
  63. ?>
espero te sea de ayuda suerte
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way