I am looking into an issue with javscript session cookies.
The situation is this, we have a main browser window, this creates a cookie, the initial value is an empty string.
document.cookie = "MyCookie_<%=UserID%>=" + value;
When a new window is opened (CTRL+N), this checks for the cookie, sees it has no value and then generates an id for the value, so we would have MyCookie_SomeUserID=12345 or whatever.
The issue we seem to have is that the original window when we do something like
var cookiestr = document.cookie;
var name = "MyCookie_<%=UserID%>";
var cookie = cookiestr.split(";");
for(var i = 0; i < cookie.length; i++) {
var cookiePart = cookie[i].split("=");
cookiePart[0] = cookiePart[0].replace(/^\s+|\s+$/g, '');
if(cookiePart[0] == name) {
if(cookiePart.length > 1) {
return cookiePart[1];
}
}
}
if we split on the "=" we don't have an id it is the original blank string that this browser window used when creating the cookie, so cookiePart[1] always = "" it's like it can share the cookie with the session for the new window, but the new window can't share it's session cookie back with the original window.
Has anyone experienced/got around this?