Ckeck if cookies are enables in IE? (works in Firefox)

A

Apaxe2000

Hi.

I create this function to verify if cookies are enables in the
browser.

<script type="text/javascript" language="JavaScript">
document.cookie = "TemporaryTestCookie=yes;";
if(document.cookie.indexOf("TemporaryTestCookie=") == -1) {
alert("Atention: You have to set cookies on.");
}
</script>

This function works well in Firefox, but dont work im Microsoft
Internet Explorer 6.

Why? I dont undestand why!

Can anyone helpme? Thanks.
 
L

Laurent Bugnion

Hi,
Hi.

I create this function to verify if cookies are enables in the
browser.

<script type="text/javascript" language="JavaScript">
document.cookie = "TemporaryTestCookie=yes;";
if(document.cookie.indexOf("TemporaryTestCookie=") == -1) {
alert("Atention: You have to set cookies on.");
}
</script>

This function works well in Firefox, but dont work im Microsoft
Internet Explorer 6.

Why? I dont undestand why!

Can anyone helpme? Thanks.

I am not totally sure why it doesn't work in IE (no time for extensive
checks, sorry), my guess is that it has to do with the path.

Anyway, check this page. I published my cookie object recently, and it
offers methods doing exactly what you want. Check the code and feel free
to use it.
http://www.galasoft-lb.ch/myjavascript/CCookie/index.html

HTH,
Laurent
 
M

marss

Apaxe2000 напиÑав:
Hi.

I create this function to verify if cookies are enables in the
browser.

<script type="text/javascript" language="JavaScript">
document.cookie = "TemporaryTestCookie=yes;";
if(document.cookie.indexOf("TemporaryTestCookie=") == -1) {
alert("Atention: You have to set cookies on.");
}
</script>

This function works well in Firefox, but dont work im Microsoft
Internet Explorer 6.

Why? I dont undestand why!

Can anyone helpme? Thanks.

There is the standard functionality that works both IE (5.0 and more)
and Firefox
if (window.navigator.cookieEnabled)
{
//....
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,048
Members
48,769
Latest member
Clifft

Latest Threads

Top