Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Two-part cookie script needed

    I submitted a long-winded request last week that got no replies so here is a less verbose version:

    First page: need a set cookie script
    Second page: need a read cookie + redirect (if the cookie exists).

    I tried using an existing script that performs all of those functions on one page but have not been able to rework the script to separate the functions. If anyone wants to look at what I have, it's posted below. Thanks for any help

    Existing script:
    <script>
    <!--

    // page to go to if cookie exists
    go_to = "otherpage.html";

    // number of days cookie lives for
    num_days = 60;
    function ged(noDays){
    var today = new Date();
    var expr = new Date(today.getTime() + noDays*24*60*60*1000);
    return expr.toGMTString();
    }

    function readCookie(cookieName){
    var start = document.cookie.indexOf(cookieName);
    if (start == -1){
    document.cookie = "seenit=yes; expires=" + ged(num_days);
    } else {
    window.location = go_to;
    }
    }

    readCookie("seenit");
    // -->
    </script>

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a cookie script that is quite simple to use:
    http://www.vladdy.net/webdesign/cookies.html
    - 3 lines of code to set a cookie, 2 lines to read (you can actually make it 1) plus your redirection line.
    Last edited by Vladdy; 12-13-2002 at 01:35 PM.
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hehheh, deacon have you ever tried searching

    ...I posted this for someone anly a few days ago

    http://www.codingforums.com/showthre...threadid=11239

    Dunno if it's what you want (vladdy's is shorter) but it works for me

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."


  •  

    Posting Permissions

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