RE: [PHP] Session Headaches

From: Date: Tue, 21 Aug 2001 22:33:20 +0000
Subject: RE: [PHP] Session Headaches
Groups: php.general 
Request: Send a blank email to php-general+get-63786@lists.php.net to get a copy of this message
OK, the session_is_registered() thing is correct. > It seems like the gist of the problems is that different > pages can't seem to > modify the same session variables. This is definitely not the case. Two things to try: 1. In page2, put some logic around the "session_register("FailedLogins");", otherwise you re-register on every visit. I don't think this affects the variable's value, but it is definitely wasted cycles. 2. If register_globals is set to "on" in php.ini, and you are using a PHP version earlier than 4.0.6, then the code below probably won't work. If this is the case, just use the global variable, $FailedLogins, instead of $HTTP_SESSION_VARS["FailedLogins"] everywhere. Kirk > -----Original Message----- > From: Johnny Nguyen [mailto:johnny@zugara.com] > Sent: Tuesday, August 21, 2001 1:58 PM > To: php-general@lists.php.net > Subject: [PHP] Session Headaches > > > I have two pages page1.php and page2.php > > here is the code for page1.php: > > <? > session_start(); > if (session_is_registered != 1) { > session_register("FailedLogins"); > $HTTP_SESSION_VARS["FailedLogins"] = 0; > } > > if ($HTTP_SESSION_VARS["FailedLogins"] > 3) { > echo "you have made " . > $HTTP_SESSION_VARS["FailedLogins"] . " login > attempts"; > } > ?> > <a href="page2.php">Simulate a failed login</a> > > > > here is the code for page2.php: > <? > session_start(); > session_register("FailedLogins"); > $HTTP_SESSION_VARS["FailedLogins"]++; > Header("Location: page1.php"); > ?> > > Ok. so after i click on my link to simulate failed logins 3 > times, I should > see the number of failed logins. > It seems like the gist of the problems is that different > pages can't seem to > modify the same session variables.

« previous php.general (#63786) next »