Re: one out of four session variables lost

From: Date: Tue, 19 Aug 2003 20:24:35 +0000
Subject: Re: one out of four session variables lost
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-160077@lists.php.net to get a copy of this message
From: "anders thoresson" <listor@thoresson.net> > > $_SESSION['uname'] = $_POST['uname']; > > $_SESSION['pwd'] = $_POST['pwd']; > > When the user first logs in I also adds two more session variables within > accesscontrol(): > > $_SESSION['editor'] = mysql_result($result,0,"u_editor"); > $_SESSION['admin'] = mysql_result($result,0,"u_admin"); > > Both is either an Y or a N. When showing menus, I use these two session > variables to decide wether editor and admin menus should be shown to the > present user. Like this: > > include ("schedule.php"); > if ($_SESSION['editor'] == "Y") > include ("editor.php"); > if ($_SESSION['admin'] == "Y") > include ("admin.php"); > > But something strange happens. Sometime, while an user who is both admin > and editor is logged in, the $_SESSION['editor'] variable is dropped, > causing the editor menu not being shown. > A check through all my source code shows that the only instance where I > assign is in accesscontrol() shown above. > > Are there any known circumstances where session variables are lost? > > (I guess that the answer is no, and this is an error caused by myself, but > since I can't find it, I have to ask ;) I'll say that the answer is no, also. If it's a case of one session variable being "lost" while the others remain, then it's a problem with your code. somewhere, somehow, you're assigning a value to that session variable and not realizing it. If all of the session variables are lost, then it's still a problem with your code and there are more possibilities. Perhaps the session ID isn't being transmitted or the domain is changing? ---John Holmes...

« previous php.general (#160077) next »