SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS newb needs help with simple cookie/redirect script

    Hello all,

    I've been reading JS cookie tutorials like mad, but cannot quite get this right. It should be a simple script to write, but I'm not getting a handle on it. So I turn to the gurus here for some help!

    I want a JS script on an index.html page that redirects a user to another page automatically (that's the easy part, and I'd just use meta-refresh if that's all I wanted). But I need to redirect them the first time only, and then if they have been there before, not redirect them. So I want the index page to check if a cookie exists and if not, redirect the user. If there is a cookie, it simply does nothing. The index page would also need to set the cookie the first time, obviously.

    Can anyone point me to a script that does this, or point me to a tutorial that lays it out clearly? I would appreciate it very much.

    Thanks so much,
    m.

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I know it was a bit of a convoluted request. I wouldn't have set up the site this way, but unfortunately I didn't code it, and I cannot change it. The problem is that the splash page is called splash.html, and the home page called index.html. I wanted to simply rename the splash page to index, and rename the index to home.html or something (very easy to do in DW) but my request was denied. So I have to find a way to work this.

    What I'm thinking might be a better way to approach this is the following:

    Set the splash.html page to set a cookie so that when visitors see it, the cookie is set. They then click "enter the site" and go to index.html. In the head of index.html, I do a JS if/then check: if the cookie doesn't exist, then do a meta-refresh to the splash page. Else the cookie exists, so do nothing.

    I'm going to try to write that code myself, I think I can do it. If anyone has any pointers, please let me know.

    Thanks to all who viewed this.

    m.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •