- Have you checked the client-side and server-side cookie domains and paths to ensure they're the same?
- Is one cookie secure and the other not?
- Other than that, I would suspect server/client clock sync issues, as Erlend suggests.
- http://stackoverflow.com/questions/55860/why-cant-i-delete-this-cookie
Dicussing....
The following script is only works in IE8
<html>
<head>
<script type="text/javascript" language="javascript">
//******************************************************************************************
// To add cookie information to the HTTP header need to use the following Syntax:
//
// document.cookie = "name=value; expires=date; path=path;domain=domain; secure";
//
// This function sets a client-side cookie as above. Only first 2 parameters are required
// Rest of the parameters are optional. If no CookieExp value is set, cookie is a session cookie.
//******************************************************************************************
function setCookie(CookieName, CookieVal, CookieExp, CookiePath, CookieDomain, CookieSecure)
{
var CookieText = escape(CookieName) + '=' + escape(CookieVal); //escape() : Encodes the String
CookieText += (CookieExp ? '; EXPIRES=' + 'Thu, 01-Jan-1970 00:00:01 GMT' : '');
CookieText += (CookiePath ? '; PATH=' + CookiePath : '');
CookieText += (CookieDomain ? '; DOMAIN=' + CookieDomain : '');
CookieText += (CookieSecure ? '; SECURE' : '');
document.cookie = CookieText;
}
// This functions reads & returns the cookie value of the specified cookie (by cookie name)
function getCookie(CookieName)
{
var CookieVal = null;
if(document.cookie) //only if exists
{
var arr = document.cookie.split((escape(CookieName) + '='));
if(arr.length >= 2)
{
var arr2 = arr[1].split(';');
CookieVal = unescape(arr2[0]); //unescape() : Decodes the String
}
}
return CookieVal;
}
// To delete a cookie, pass name of the cookie to be deleted
function deleteCookie(CookieName)
{
var tmp = getCookie(CookieName);
if(tmp)
{
setCookie(CookieName,tmp,(new Date(1))); //Used for Expire
}
}
alert(getCookie('LOGGEDIN_SESSION'));
setCookie("LOGGEDIN_SESSION", "", -1);
alert(getCookie('LOGGEDIN_SESSION'));
function clearCookie(name, domain, path){
var domain = domain || document.domain;
var path = path || "/";
document.cookie = name + "=; expires=" + "Thu, 01-Jan-1970 00:00:01 GMT"+ "; domain=" + domain + "; path=" + path;
};
alert(document.domain)
clearCookie('LOGGEDIN_SESSION');
alert(getCookie('LOGGEDIN_SESSION'));
</script>
</head>
<body>
</body>
</html>