[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.phpSimulate 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. any ideas? thanks everyone. regards, Johnny Nguyen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Session Headaches
Start with this correction on page1.php: if (session_is_registered != 1) { should be if (session_is_registered(FailedLogins) != 1) { We'll go from there :) Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Session Headaches
oops. of course that's what i meant. -Original Message- From: Johnson, Kirk [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 1:56 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] Session Headaches Start with this correction on page1.php: if (session_is_registered != 1) { should be if (session_is_registered(FailedLogins) != 1) { We'll go from there :) Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Session Headaches
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:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 1:58 PM To: [EMAIL PROTECTED] 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.phpSimulate 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Session Headaches
I am using php 4.0.6 and i would rather not use global variables. regards, Johnny Nguyen -Original Message- From: Johnson, Kirk [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 3:33 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] Session Headaches 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:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 1:58 PM To: [EMAIL PROTECTED] 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.phpSimulate 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Session Headaches
I am using php 4.0.6 and i would rather not use global variables. I hear ya. After playing around with this, your approach works if register_globals is set to off (I did this with an .htaccess file). I'm surprised by this. It appears that the global version of a variable still overwrites the HTTP_SESSION_VARS version when the script ends and the data is stored to the session file, in spite of the change in this area in 4.0.6. This is not the behavior I expected with this bug fix, but it appears to be the case. Since your code never sets the global version of $FailedLogins, nothing gets stored in the session. Unless I'm missing something, it looks like register_globals needs to be off to use session variables the way your code does. In case you haven't done this before, create .htaccess with this line: php_flag register_globals off All for me on this day. Good luck! Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]