View Full Version : Session cookie not ending in IE

Mr J
06-28-2006, 12:04 PM
Cookie name is "viewStatus" value saved is 1

Closing all windows should end the session but on the reopening cookie page I find the session cookie is still alive.

If I alert(document.cookie) I get viewStatus = 1

If I rename the cookie to say "vStatus" and close the window when I reopen it and alert(document.cookie) I get

viewstatus=1 vStatus=1

any ideas?

This only happens in IE ( as always)


I just did a little experiment, I closed all windows, created a new file with just


in it then opened the file and still got

viewstatus=1 vStatus=1

I know I did not have this problem before because I have a session cookie example on my site and that does not work now so is it something new that is wrong with IE

06-28-2006, 02:53 PM
And how are you setting the cookie?


Mr J
06-28-2006, 04:32 PM
Here's some code, clicking the link reveals a div and sets the session cookie.

When I close and then reopen the page the cookie still exists when the session cookie should expire on closing the window, the only way I can get it to expire is to reboot my pc

<TITLE>Document Title</TITLE>

<script type="text/javascript">

function getDivStatus(){

alert("Cookie Value = "+getCookie("viewStatus"))





function getCookie(name){
var cookieName = name + "="

var cookieValue = ""
if(document.cookie.length > 0){
startIndex = document.cookie.indexOf(cookieName)

if(startIndex != -1) {
startIndex += cookieName.length

endIndex = document.cookie.indexOf(";", startIndex)

if(endIndex == -1){
endIndex = document.cookie.length

cookieValue=unescape(document.cookie.substring(startIndex, endIndex))



return cookieValue


function showHide(num){





<BODY onload="getDivStatus()">

<a href="#null" onclick="showHide(0)">Show Div 1</a><BR>
<div id="div0" style="width:300px;height:50px;background-color:#55aa55;display:none">Div 1</div>