jyushinx Posted November 29, 2007 Share Posted November 29, 2007 Hi, I am having a bit of an issue working with a PHP session in IE7. I'm just starting to set this up, so for informational purposes, all I have is a page that starts a session and then displays the SID. Now in Firefox, I start a session and it places a session cookie on my system. If I kept refreshing this page, the cookie still exists and thus the session, so it keeps displaying the same SID. Now if I deleted the cookie, a new session would be created on my next refresh with a new SID and cookie. In IE7, I cannot find the cookie for the session. I checked using Nirsoft Cookie Viewer as well as looking myself in Windows Explorer. There is no cookie. However, when I refresh the page, the SID stays the same, as if the session is active and the cookie does exist. Perhaps it does and I just don't know where. Any ideas? Also, in regards to sessions, I was under the impression they had a default lifetime of 3 hours. However, I have left my computer for far longer than this, and when I return, it is still active. Does it only end when the browser is closed? Thanks. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 29, 2007 Share Posted November 29, 2007 Its in a hidden folder. Go to Tools, Internet Options, Under Browsing History hit Settings, then View Files. Sessions end when the browser is closed for the most part. Quote Link to comment Share on other sites More sharing options...
p2grace Posted November 29, 2007 Share Posted November 29, 2007 Hi, I believe the session max lifetimes are set in the php.ini file. I'm not sure if this is what you're asking, but in order to get IE to regenerate its session id, I usually use session_regenerate_id(); right after session_start(); Quote Link to comment Share on other sites More sharing options...
jyushinx Posted November 29, 2007 Author Share Posted November 29, 2007 revraz, I already looked in that location (that's what I meant by saying I checked with Windows Explorer) . I looked in both C:\Documents and Settings\user\Local Settings\Temporary Internet Files & C:\Documents and Settings\user\Cookies. The cookie is nowhere to be found. p2grace, I know that you can control the session lifetime in php.ini, but when it is not explicitly set (which it isn't), what is the default? Thanks. Quote Link to comment Share on other sites More sharing options...
p2grace Posted November 29, 2007 Share Posted November 29, 2007 If it isn't specified it's lifetime is set to 24 inactive minutes. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 29, 2007 Share Posted November 29, 2007 Session Life is not the same as the cookie written to the client PC. Session Life is how long the session will be left on the Server in your session save path and the GC won't delete it. Quote Link to comment Share on other sites More sharing options...
jyushinx Posted November 29, 2007 Author Share Posted November 29, 2007 I understand they are different, but it seems that if the cookie is not present, the session is no longer valid. You can see this by the way it behaves in Firefox. The cookie is set with an SID. If I delete the cookie and try to refresh the page a new session is started along with a new SID. With IE, I just closed the program and reopened it. I navigated to the page in question and was prompted to set my session cookie with an expiry marked as "End of session". I clicked allow and voila, I cannot find this cookie anywhere. Where is it going? It has to be somewhere. Quote Link to comment Share on other sites More sharing options...
p2grace Posted November 29, 2007 Share Posted November 29, 2007 What exactly are you trying to accomplish by finding where it's stored? Quote Link to comment Share on other sites More sharing options...
jyushinx Posted November 30, 2007 Author Share Posted November 30, 2007 Well my initial motivation was because I was going to delete the cookie to make sure that when I refreshed the page, a new Session was generated. That wasn't a pressing issue or anything, but now I want to know for information's sake. I like to understand how it functions because I don't like assuming things will just "work" without understanding the underlying mechanism. I've found that this sort of assumption leads to more trouble if you ever run into a problem down the road. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 30, 2007 Share Posted November 30, 2007 The IE cookie question is really very simple. Any cookie with a zero life time is kept in a cookie cache in memory (which is deleted when the browser closes.) For the second question, as long as the browser is left open (even if you browse to a different site) the session cookie is kept alive. However, if the session garbage collection runs on the server and deletes the corresponding session data file, then the session cookie would no longer have a corresponding session data file when the browser fetches a URL at your site. Quote Link to comment Share on other sites More sharing options...
jyushinx Posted November 30, 2007 Author Share Posted November 30, 2007 That makes sense. Thanks for the explanation. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.