SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know that this is a rather simplistic question, but I want to create a cookie that will redirect a visitor (on their 2nd visit to the webpage) to another page. Basically so that they don't have to see the whole flash show every time they come to the webpage (they just see it the 1st time). I know that this is done everywhere...I've looked all over for a script but I've had no luck.

    Any suggestions or code they wanna share?

    Thanks!
    Joseph Schell
    AMICO-Online

  2. #2
    I believe you have my stapler. scrubz's Avatar
    Join Date
    Feb 2001
    Location
    Van down by the river
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this in the head of your page. It checks for a cookie. If it's there, it redirects to index2.html. If the cookie isn't there, it stays on index.html and writes the cookie. Mmmmm....cookies.

    <script language="JavaScript">
    <!--

    if (document.cookie)
    {window.location.href="index2.html"}
    else
    {setCookie('myCookie','oatmeal','Thu, 01-Jan-2010 00:00:01 GMT') }

    function setCookie(name,value,expires,path,domain,secure)
    { document.cookie = name + "=" +escape(value) + ( (expires) ? ";expires=" + expires: "") + ( (path) ? ";path=" + path : "") + ( (domain) ? ";domain=" + domain : "") + ( (secure) ? ";secure" : "");
    }

    // -->
    </script>

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That worked wonderfully! Thanks a bunch for the script!
    Joseph Schell
    AMICO-Online


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
  •