adcworks Posted January 17, 2007 Share Posted January 17, 2007 hi guys, this is a really odd problem i am having here, and one which i have never in my years of php development seen before hm. embarrassing.i have a form that requires a user login and a successful login adds a user object into the session. the form only displays the login fields when there is no session user object.the problem is, i can never login again, in that every time i hit the form page, it shows that i am already logged in (from that session check). i have closed all my browser instances and go back, and it's still logged in. i debugged out session_id and even when i reopen browsers i am always getting the same session id.so here is something really interesting ... i added a logout button to the form which calls session_destroy(). this has no effect whatsoever and nor does session_unset. session.cookie_lifetime = 0, so sessions ought to die on browser close.some more interesting things I have noticed. the problem occurs on both IE7 and FireFox in that once I have logged in once, the logout (session_destroy) has no effect. HOWEVER in FireFox, a browser close *does* cause the login prompts to appear the next time.And *finally* if I do a cookie clear in IE 7's tools, then when I start a new browser, the login works again!!So the problem summarised appears to be that IE7 is not clearing the session cookie when I close the browser down and only works when I do it from the tools menu, whereas FireFox does clear the cookies. However in BOTH IE7 and FireFox session_destroy/unset does not work in unsetting the user object.Any ideas at all? Link to comment https://forums.phpfreaks.com/topic/34513-session-persisting-across-browser-close-and-session_destroys/ Share on other sites More sharing options...
kenrbnsn Posted January 17, 2007 Share Posted January 17, 2007 Please post your code.Ken Link to comment https://forums.phpfreaks.com/topic/34513-session-persisting-across-browser-close-and-session_destroys/#findComment-162581 Share on other sites More sharing options...
adcworks Posted January 17, 2007 Author Share Posted January 17, 2007 2 things to notea) the problem with the logout link I determined as my fault, i had not done session_start before session_unset, so that works when i explicitly call session_unset nowb) the problem appears to be IE7 only and sessions do persist over time and browser instances. i have written a small test case that proves this for my own machine setup posted belowbasically, the first time i ran this in IE7 the message "old value" was printed. Now, regardless of closing all browsers down when I run the script it gives always "new value".[code]<?class MyClass { var $value; function __construct() { $value = "old value"; } function getValue() { return $this->value; } function setValue($value) { $this->value = $value; } }session_start();if (isset($_SESSION['myclass'])) { $class = $_SESSION['myclass'];} else { $class = new MyClass(); $class->setValue("new value"); $_SESSION['myclass'] = $class;}echo $class->getValue();?>[/code] Link to comment https://forums.phpfreaks.com/topic/34513-session-persisting-across-browser-close-and-session_destroys/#findComment-162609 Share on other sites More sharing options...
adcworks Posted January 17, 2007 Author Share Posted January 17, 2007 that code actually proves nothing, it works as expected on my machine. i think the problem must be related to something else, it's difficult to post the full code of my setup as it's a complex multi-script system with AJAX also used.sigh .. i will just have to debug :) Link to comment https://forums.phpfreaks.com/topic/34513-session-persisting-across-browser-close-and-session_destroys/#findComment-162613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.