Click to See Complete Forum and Search --> : Cookies and IE6; a dilemma


AStromer
September 10th, 2002, 10:56 AM
Does anyone know something about that new feature in IE6 with enabling-disabling cookies (silly but the people wanted it because there are soooo bad informations in it). My actual problem is a webpage where I use ASP-Session-Cookies for the server-client connection integrated in IIS-ASP or whatever; the main thing is that Session-Cookies are used.
So I have to get sure that the client does accept cookies. I use the client javascript-function navigator.CookieEnabled to get the information if the browser accepts cookies or not. It does it job with all browsers except of IE6 (with its new Cookie-Manager-Tool). The function always returns true but the browser in fact does not accept cookies.

So is there anybody who has the same problems or knows a workaround with other functions so I can get the settings of the browser ?

Zvona
September 11th, 2002, 02:52 AM
Originally posted by AStromer
Does anyone know something about that new feature in IE6 with enabling-disabling cookies (silly but the people wanted it because there are soooo bad informations in it). My actual problem is a webpage where I use ASP-Session-Cookies for the server-client connection integrated in IIS-ASP or whatever; the main thing is that Session-Cookies are used.
So I have to get sure that the client does accept cookies. I use the client javascript-function navigator.CookieEnabled to get the information if the browser accepts cookies or not. It does it job with all browsers except of IE6 (with its new Cookie-Manager-Tool). The function always returns true but the browser in fact does not accept cookies.

So is there anybody who has the same problems or knows a workaround with other functions so I can get the settings of the browser ?

Replace that sentence with :
client-side Javascript property navigator.cookieEnabled
..poof..you have no problems anymore.

IE6 follows standards more strictly and isn't as loose with incorrect syntax as earlier versions.

AStromer
September 11th, 2002, 03:33 AM
Made a mistake in writing the post, sorry for that.

It is "cookieEnabled"; I already know that C, Javascript , ... is case sensitive.

If you would try what I've said you would see what I mean. It doesn't work, okay. Disable Cookies in IE6 in the privacy tab and then check the property. Shame on M$. It doesn't work. Explicitly that point they worked on doesn't work.

AStromer
September 11th, 2002, 03:45 AM
Here is my code, try it on your own in IE6 with blocking all cookies in the privacy tab :

*********code**********

<html><head>
<title></title>
<noscript><meta http-equiv="refresh" content="0; URL=noscript.htm"></noscript>
<script language="JavaScript">


var btyp;
var mylanguage;
var OP, NC4, NC6, IE;
var CookiesEnabled;
NC6 = 0;
NC4 = 1;
OP = 2;
IE = 3;



if (navigator.userAgent.indexOf("Opera") != -1)
{
btyp=OP;
}
else
{
if (navigator.appName == "Netscape")
{
if (navigator.userAgent.indexOf("Mozilla/4.") != -1)
{
btyp=NC4;
}
else
{
btyp=NC6;
}
}
else if (navigator.appName == "Microsoft Internet Explorer")
{
btyp=IE;
}
}


CookiesEnabled = true;

switch(btyp)
{
case 0:
{
//Netscape 6-Series

//Cookies enabled ?
if (!navigator.cookieEnabled)
{
window.location.href="nocookie.htm"
CookiesEnabled = false;
}

//Read Language
mylanguage = navigator.language.substr(0,2);

break;
}
case 1:
{
//Netscape 4-Series

//Netscape 4 is not supported
window.location.href = 'getnewbrowser.htm';
CookiesEnabled = false;

break;
}
case 2:
{
//Opera-Series

//Cookies enabled ?
if (!navigator.cookieEnabled)
{
window.location.href="nocookie.htm"
CookiesEnabled = false;
}

//Read Language
mylanguage = navigator.language;
break;
}
case 3:
{
//Internet Explorer-Series

//Cookies enabled ?
if (!navigator.cookieEnabled)
{
window.location.href = 'nocookie.htm';
CookiesEnabled = false;
}
alert(navigator.cookieEnabled);

//Read Language
mylanguage = navigator.userLanguage.substr(0,2);

break;
}
}


if (CookiesEnabled)
{
switch(mylanguage)
{
case "en":
{
//Englisch
window.location.href = "/en";
break;
}
case "de":
{
//Deutsch
window.location.href = "/de";
break;
}
case "it":
{
//Italienisch
window.location.href = "/it";
break;
}
case "cs":
{
//Tschechisch
window.location.href = "/cz";
break;
}
default:
{
//Andere Sprache
window.location.href = "/de";
break;
}
}
}

</script>
</head>
<body>

</body>
</html>


*********code**********

thx

AStromer
October 4th, 2002, 05:13 AM
Here is it; that works and that's the only way to do it.
cookieEnabled doesn't work correctly in IE6

<script language='Javascript'>

var MyStringLength;
document.cookie = 'IgnoreThisCookieTest';
MyStringLength = document.cookie.length;
if(document.cookie.substring(MyStringLength-20,MyStringLength)=='IgnoreThisCookieTest')
{
alert('Cookies allowed');
}
else
{
alert('Cookies forbidden);
}

</script>


I just post it because I searched and searched and didn't get the answer for my question. So here is the answer.