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 strongm 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.

JavaDude32

Programmer
Aug 25, 2001
180
US
Alright, I have a script so far and I tested it in Mozilla and it seems to work, but no such luck in IE. The idea is to determine if the user has cookies enabled. If the user doesn't have at least cookies enabled for first-party cookies or cookies from the originating site, it redirects them to the help page. Can anyone help me find what's going wrong?

Code:
<script language="JavaScript">
  if(document.cookie) {
  } else {
    if(document.location.href=="[URL unfurl="true"]http://mainsite/")[/URL] {
      window.alert("You need to enable cookies.");
      document.location.href="[URL unfurl="true"]http://mainsite/help/";[/URL]
    }
  }
</script>

P.S. Reason for this script is that the website requires cookies to be able to navigate around lessons. Plus it allows the user to return to a lesson rather then restart.
 
Try to write a cookie, then read it. If you can then they're enabled. Here's a link for more info: Intelligent Cookies

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
I realized I could try that, however, an issue is the internal browser cookie limit that is already reached by the website. I don't really want a dummy cookie replacing necessary information that can't really be reset. All the cookies used are written using server side scripts. So I was hoping for a solution to tell me this without having to actually mess with setting a cookie.
 
Well, if a cookie already exists from your website then you don't have to set one, just try to read the one that's already set. If it's blank, then redirect them.

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top