Foros del Web » Programando para Internet » PHP »

Timeout en login con $_SESSION

Estas en el tema de Timeout en login con $_SESSION en el foro de PHP en Foros del Web. Buen día Amigos ¿Como Andan? Les cuento que estoy con un inconveniente, tengo un script de login de usuarios con $_SESSION, a eso quiero agregarle ...
  #1 (permalink)  
Antiguo 03/12/2010, 07:50
 
Fecha de Ingreso: noviembre-2010
Ubicación: Capital Federal, Buenos Aires
Mensajes: 60
Antigüedad: 13 años, 4 meses
Puntos: 0
Timeout en login con $_SESSION

Buen día Amigos ¿Como Andan? Les cuento que estoy con un inconveniente, tengo un script de login de usuarios con $_SESSION, a eso quiero agregarle timeout, el tema es que no se donde agregarlo ni como agregarlo, les muestro los archivos armados.-


Archivo auth.php (incluyo en cada archivo que quiero que tenga login)
Código PHP:
<?php
    session_start
();
    
    if(!isset(
$_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
        
header("location: login.php");
        exit();
    }
?>
Archivo: login-exec.php
Código PHP:
<?php
    
//Start session
    
session_start();
    
    
//Include database connection details
    
require_once('config.php');
    
    
//Array to store validation errors
    
$errmsg_arr = array();
    
    
//Validation error flag
    
$errflag false;
    
    
//Connect to mysql server
    
$link mysql_connect(DB_HOSTDB_USERDB_PASSWORD);
    if(!
$link) {
        die(
'Fallo la coneccion con el servidor!: ' mysql_error());
    }
    
    
//Select database
    
$db mysql_select_db(DB_DATABASE);
    if(!
$db) {
        die(
"Base de datos no encontrada");
    }
    
    
//Function to sanitize values received from the form. Prevents SQL injection
    
function clean($str) {
        
$str = @trim($str);
        if(
get_magic_quotes_gpc()) {
            
$str stripslashes($str);
        }
        return 
mysql_real_escape_string($str);
    }
    
    
//Sanitize the POST values
    
$login clean($_POST['login']);
    
$password clean($_POST['password']);
    
    
//Input Validations 

    
if($login == '') {
        
$errmsg_arr[] = 'Id incorrecto';
        
$errflag true;
    }
    if(
$password == '') {
        
$errmsg_arr[] = 'Password incorrecto.';
        
$errflag true;
    }
    
    
//If there are input validations, redirect back to the login form
    
if($errflag) {
        
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
        
session_write_close();
        
header("location: login.php");
        exit();
    }
    
    
//Create query
    
$qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'";
    
$result=mysql_query($qry);
    
    
//Check whether the query was successful or not
    
if($result) {
        if(
mysql_num_rows($result) == 1) {
            
//Login Successful
            
session_regenerate_id();
            
$member mysql_fetch_assoc($result);
            
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
            
$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
            
$_SESSION['hora']=time();
            
session_write_close();
            
header("location: index.php");
            exit();
        }else {
            
//Login failed
            
header("location: login-error.php");
            exit();
        }
    }else {
        die(
"Fallo el Query!");
    }
?>
Archivo login.php
Código PHP:
<html xmlns="http://www.w3.org/1999/xhtml"
<
head
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<
title>ETL Computaci&oacute;Formulario de Contacto Base de Datos Login</title
<
link href="style.css" rel="stylesheet" type="text/css"/>
</
head>
<
body>
<
form id="loginForm" name="loginForm" method="post" action="login-exec.php">
  <
table width="200" border="0" align="center">
    <
tr>
      <
td>Usuario: </td>
      <
td><input name="login" type="text" id="login" /></td>
      </
tr>
    <
tr>
      <
td>Password:</td>
      <
td><input type="password" name="password" id="password" /></td>
      </
tr>
    <
tr>
      <
td colspan="2"><input name="Submit" type="submit" id="entrar" value="Entrar" /></td>
      </
tr>
  </
table>
</
form>
<
div align="center"><a href="resetmail/"><p>¿Olvid&oacutesu contrase&ntilde;a?</p></a></div>
</
body>
</
html

Gracias a todos por la ayuda!!
  #2 (permalink)  
Antiguo 03/12/2010, 11:16
 
Fecha de Ingreso: septiembre-2009
Mensajes: 210
Antigüedad: 14 años, 7 meses
Puntos: 19
Respuesta: Timeout en login con $_SESSION

Hace algo de tiempo pusieron esto por el foro, te lo pongo por si te sirve:

http://www.forosdelweb.com/f18/confi...siones-533855/

Saludos
  #3 (permalink)  
Antiguo 03/12/2010, 12:23
 
Fecha de Ingreso: noviembre-2010
Ubicación: Capital Federal, Buenos Aires
Mensajes: 60
Antigüedad: 13 años, 4 meses
Puntos: 0
Si, traté de armarlo igual pero me da error! ¿Alguna sugerencia? Gracias

¿Alguien me puede ayudar? Probé de muchas maneras poner el código y no funciona.- Gracias!

Última edición por GatorV; 06/12/2010 a las 10:33
  #4 (permalink)  
Antiguo 08/12/2010, 18:01
 
Fecha de Ingreso: noviembre-2010
Ubicación: Capital Federal, Buenos Aires
Mensajes: 60
Antigüedad: 13 años, 4 meses
Puntos: 0
Respuesta: Timeout en login con $_SESSION

Alguna ayuda? Sigue sin funcionarme.-


Muchas Gracias y disculpas por las molestias

Etiquetas: login, session, timeout
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:34.