Results 1 to 3 of 3

Thread: Cookie redirect

  1. #1
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Cookie redirect

    Help!

    Essentially what I am after is a cookie that on first visit opens page x.htm - writes a value, say 1, back to the cookie.

    When the user next visits, the cookie reads the value 1 and redirects to page x2.htm and writes the value 2, next visit to x3.htm and so on to whatever value and then after say 10 different pages returns to page x.htm !

    I am aware that this will not trap users that override normal cookie handling but I am prepared to miss a few users.

    At the moment I am using JavaScript to randomize the pages but this is a very inelegant way of getting the job done!

    Thing is I have never written a cookie - does anyone out there have one that will do the trick?


    <body bgcolor="#C0C0C0" bottommargin="0" onload="go()" bgcolor="#C0C0C0">

    <SCRIPT LANGUAGE="JavaScript">
    var urlarray= new Array(
    "index1.htm",
    "index2.htm",
    "index3.htm",
    "index4.htm",
    "index5.htm",
    "index6.htm",
    "index7.htm",
    "index8.htm",
    "index9.htm",
    "index10.htm",
    "index11.htm",
    "index12.htm",
    "index13.htm",
    "index14.htm",
    "index15.htm",
    "index16.htm",
    "index17.htm",
    "index18.htm",
    "index19.htm",
    "index20.htm",
    "index21.htm",
    "index22.htm",
    "index23.htm",
    "index24.htm",
    "index25.htm",
    "index26.htm");

    randomno=Math.floor((Math.random()*urlarray.length));

    urlran=urlarray[randomno]

    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">
    function go(){
    var url =urlran
    var target="_self"
    window.open(url,target)
    }
    </SCRIPT>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Cookies at Quirksmode is a very good unit for this. A one page primer, if you will, with example code that will do all the hard parts for you.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Many thanks - I will have a look!

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
  •