I have a single session for a website in IE 8+, and I assume that the user can open several tabs. In the main window, the user will open other tabs from it on the same session, but when the session times out in any of the other tabs, all of the tabs of the application need to close. What is the best way to track the time of the session in all of the tabs if the time can only be tracked client-side? My first thought was using a cookie, but I want to hear other suggestions.
Asked
Active
Viewed 64 times
0
-
Search here for localStorage - whenever one of your tabs put something there, all the other tabs can receive the storage event. – JustAndrei Oct 25 '13 at 19:11
-
@JustAndrei Assuming they are on the same domain, as I understand it. – dougajmcdonald Oct 25 '13 at 19:12
-
However, you may find it problematic to close the tab from your javascript - this action may be blocked as it hasn't been explicitly initiated by the user. – JustAndrei Oct 25 '13 at 19:13
-
@dougajmcdonald, sure. The quote: "all of the tabs _of the application_ need to close". – JustAndrei Oct 25 '13 at 19:14
-
And there's a problem with localStorage (it was never easy, right?): in Private (Incognito) mode some browsers put a quota on localStorage, effectively making it read-only. – JustAndrei Oct 25 '13 at 19:17
-
well, the session is usually a server-side thing, persisted using a cookie. since the cookie is set as an HTTP cookie, it can't be accessed via javascript. therefore, your server will need to play a part in triggering the fact that a session has expired. – Kevin B Oct 25 '13 at 19:22
-
check out this post for Java solution http://stackoverflow.com/a/21225958/3213575 – DTB Jan 20 '14 at 07:56
2 Answers
0
I have a similar requirement in my project. The need to make two windows to comunicate, in our scenario the best solution was:
page1.html
var page2 = window.open("page2.html");
var id = setInterval(function(){
page2.integrateData(jsonData);
}
page2.html
function integrateData(JsonValue){
//integrate your data
}
UPD: we use the IE8 too.

Claudio Santos
- 1,307
- 13
- 22
-
If I passed in the primary object that contained the data, would updating this object in page2 change what page1 sess? – FearlessFuture Oct 25 '13 at 19:55