Results 1 to 2 of 2

Thread: Cookie help

  1. #1

    Thread Starter
    Lively Member jamieoboth's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    116

    Question Cookie help

    Hey

    I have a text box, in which a user enters his/her name. How can I set it so that it 'saves' the users name via a cookie, and then recalls it into the same text box, next time the user visits the page?


    Thanks for your help


    James
    Ich widerstehe allem - nur nicht der Versuchung

    (I can resist anything but temptation)

  2. #2
    Lively Member
    Join Date
    Dec 2002
    Location
    southwest pennsylvania
    Posts
    65
    <head>
    <script language="javascript">
    <!--
    function checkC()
    {
    var the_cookie=unescape(document.cookie).split(":");
    if(the_cookie[1])
    {
    document.getElementById("username").value=the_cookie[1];
    document.getElementById("cName").style.visibility="hidden";
    }
    }
    function savecookie()
    {
    var username=document.getElementById("username").value;
    var the_date=new Date("December 31, 2023");
    the_date.toGMTString();
    document.cookie="myCookie="+escape(username);+";expires="+the_date;
    }
    -->
    </script>
    </head>
    <body onLoad="checkC()">
    <input type=text id=username>
    <input type=button onClick="savecookie" id=cName value="save cookie">
    </body>


    i didnt test this or anything. hope it works
    if you choose not to decide you still have made a choice!

    RUSH rocks!

Posting Permissions

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



Click Here to Expand Forum to Full Width