views:

684

answers:

1

I have found a fairly significant issue with IE8 with regard to setting cookie expirations to 0 (so as to log a user out when they close the browser). It seems that each new tab or window is counted as a new session, so if a user opens a page on the site in a new tab/window, they have to login again unless they selected the option to stay logged in, which makes the cookie persistent and doesn't cause any problems. There has got to be a way to make this work like it should and always has in the past without forcing my users to stay logged in even after they close the browser. If it matters, I am setting the cookies from pHP like this:

setcookie("username",$username,0," ",".example.com");
A: 

the issue could be the space in the path field. this attribute should be unspecified or should be a valid path like /home. try specifying an empty string ('') instead of space.

could also be a caching thing, i.e. the login page may appear to be unauthenticated because the content was cached. session_cache_limiter('nocache') in php would instruct the browser not to cache anything (when using sessions), which is the same as setting:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache

to omit the path, you can pass '' (empty string) or null to setcookie for that param. or use something like '/' to indicate the entire site.

ie8 windows and tabs share the same session unless the user selects "File -> New Session" or runs iexplore.exe -nomerge explicitly.

jspcal
It isn't a caching issue. Like I said, IE8 interprets each tab/window as a new session, so only persistent cookies are carried over. It is also quite obvious that caching isn't the problem because I redirect to the login page (with the page that you came from in the URL) and it does that no matter what URL.
James Simpson
I just ran HTTP Spy and I logged in on one page, and all of the cookies showed correctly. I then opened a link from the page (the link contained a random number in the URL to break cache) and it redirected to the login page. HTTP Spy didn't show any of the login cookies that show in the other tab.
James Simpson
By the way, it isn't like this is just some issue with my specific settings. I've been getting e-mails from users about it and I have tried it on multiple computers with the same results.
James Simpson
ie8 windows, tabs, and popups belong to the same session by default, so they're not isolated contexts. as for caching, if caching isn't disabled, ie will cache responses (browsing to /home or /login again might not display the current user for example, but it all depends on how the app is constructed and what the test scenario is). another thing to check would be using http spy to verify the cookie data contains the expected values
jspcal