Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookie detection

Status
Not open for further replies.

keyer

Programmer
Aug 21, 2000
18
US
Hi,
I want to simply detect whether the browser has cookies enabled, so I do as a test:

<script language='Javascript'>
<!--
if(document.cookie) {
document.write(&quot;yes to cookies&quot;);
}
else
document.write(&quot;no to cookies&quot;);
-->
</script>

With IE5.5 this returns &quot;no to cookies&quot; all the time, no matter whether I enable cookies or not.

Any idea what's going on? I also tried setting the cookie to something, like (document.cookie=&quot;&quot;)

 
Not 100% positive, but in other languages you often need to write a cookie, then reload the page, then read the cookie for this type of test to work.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top