Sessions

From: Bruno (deadlink74_at_hotmail.com)
Date: 10/28/04


Date: Thu, 28 Oct 2004 12:27:46 GMT

Hi all,

I have a problem with sessions. I've got the following code in a login
script which starts up the session and registers a variable and then
redirects to the main page.

$user_id = $query_data[1]; //Pulled from a db earlier in the script
session_start();
session_register('user_id');
$_SESSION['user_id'] = $user_id;
header("Location: http://www.mydomain.com/main.php");

When the user gets to the main page it checks to see that a session is
registered (see following code) and if it isn't it throws the user back to
the login page.

session_start();
session_register("user_id");
if (empty($user_id)) header("Location: http://www.mydomain.com/login.php");

This works fine when a user opens a new browser and logs in, however, once
the session has timed out and it throws the user back to the login page it
keeps sending the user back to the login page when they try to login. This
worked fine on a server running PHP version 4.0.6 but it has been moved to a
server running 4.3.8 and it has stopped working. Any ideas?



Relevant Pages

  • Re: Please! Doesnt anyone know a better way to do this?
    ... account, they need to automatically be directed to the page to enter data ... session variable on the Account page. ... I assume here that you're checking a database when the user attempts to ... When a new user attempts to login or clicks to register, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: nooB PhP login using MySQL
    ... This PC has MySQL and IIS configured and running. ... how do I prevent users from bypassing the login? ... create a random string and store in session on server, ... euphemism for md5) but now that there are secure ways, ...
    (comp.lang.php)
  • Re: Sessions
    ... In the php manual it is not recomended using $_SESSION and session_register ... I've got the following code in a login ... > script which starts up the session and registers a variable and then ... > server running 4.3.8 and it has stopped working. ...
    (alt.php)
  • Re: nooB PhP login using MySQL
    ... This PC has MySQL and IIS configured and running. ... how do I prevent users from bypassing the login? ... create a random string and store in session on server, ... euphemism for md5) but now that there are secure ways, ...
    (comp.lang.php)
  • Re: why a session-based program behaves different on different computers
    ... But if you lose the session you lose ... now, pray-tell, HOW IS THE DATA LOST? ... IF THERE IS NO LOGIN, HOW DO YOU DETERMINE WHICH ROW IT IS? ... let's stick to the architecture for a moment then. ...
    (comp.lang.php)