Forum Moderators: coopster
I've written a fairly straightforward session login system. And it works just great on all the computers I've tested. However, the person who is going to be using the system is experiencing a problem where once in a blue moon, seemingly without pattern or reason, after using the system successfully for awhile the session cookies expire unexpectedly and they consequently get logged out.
The code is dead simple. Stripped down, it essentially works like this.
Here's where the login page creates the auth:
session_start();
$_SESSION['auth']=TRUE;
...and on consequent pages I test for the existence of the token auth.
Apparently there were some old bugs in IE that sometimes resulted in session weirdness, but I have made certain that everyone is using the latest version of ie6. This is doubly frustrating because I have been completely unable to reproduce this bug on my end.
Has anyone ever encountered anything like this before? Can you think of anything in the configuration of a local system that would possibly cause the session cookies to expire without warning?
Am I going crazy?
Thanks for your help, much appreciated
-trav
session_start();
$sessionid = session_id();
// confirm that session is valid
$auth = mysql_result(mysql_query("SELECT COUNT(uniqueid) FROM sessiontable WHERE sessionid = '$sessionid'"),0);
if ($auth==1) { // update auth timestamp
$query = "UPDATE sessiontable SET timestamp='$nowtime' WHERE sessionid='$sessionid'";
$result = mysql_query($query)
or die("Couldn't update timestamp");
} else {
mysql_close($connection);
header("Location: logout.php");
}
session.cookie_domain. Have a look at msg #3 in this thread where the PHP Session ID - randomonly resets [webmasterworld.com].
Thanks for the help guys, much appreciated. I have a question - in cases where session.cookie_domain is what is causing a session to 'reset' itself, is the effect observable on all client systems, or does it depend on something in a clients config? (I would assume the bug would occur on all systems, and I had ruled this possibility out since I haven't been able to reproduce the problem on any of my computers... But now I'm wondering...) The problem appears to be occurring on a machine that is on a network - though why that would make any difference I have no idea...