+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    8

    Cookies with HTML

     
    There are lots of examples online that I can find that shows how to use JavaScript with HTML to set and get cookies. But so far what I have tried have not worked. Has anyone actually tried and been successful with Cookies using HTML and Javascript?

  2. #2
    Member
    Join Date
    Aug 2010
    Location
    delhi
    Posts
    30
    <HTML>
    <HEAD>
    <TITLE>Cookie</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    function setCookie(c_name,value,exdays)
    {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;
    }
    function checkCookie()
    {
    var username=null
    if (username!=null)
    {
    alert("Welcome again " + username);
    }
    else
    {
    username=prompt("Please enter your name:","");
    if (username!=null && username!="")
    {
    setCookie("username",username,365);
    }
    }
    }
    </SCRIPT>
    </HEAD>
    <BODY onload="checkCookie()">
    </BODY>
    </HTML>

    If your windows is installed in c drive check the following path
    C:\Documents and Settings\Username\Local Settings\Temporary Internet Files
    here Username is the user name with whom you have log on.

  3. #3
    Member
    Join Date
    Aug 2010
    Location
    delhi
    Posts
    30

    Script

    <HTML>
    <HEAD>
    <TITLE>Cookie</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    function setCookie(c_name,value,exdays)
    {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;
    }
    function checkCookie()
    {
    var username=null
    if (username!=null)
    {
    alert("Welcome again " + username);
    }
    else
    {
    username=prompt("Please enter your name:","");
    if (username!=null && username!="")
    {
    setCookie("username",username,365);
    }
    }
    }
    </SCRIPT>
    </HEAD>
    <BODY onload="checkCookie()">
    </BODY>
    </HTML>

    If your windows is installed in c drive check the following path
    C:\Documents and Settings\Username\Local Settings\Temporary Internet Files
    here Username is the user name with whom you have log on.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Export excel --> html - How to clean html?
    By BITM@D in forum Applications and Operating Systems
    Replies: 21
    Last Post: February 15th, 2010, 10:21 AM
  2. Cookies
    By Germain in forum Technical Support
    Replies: 9
    Last Post: April 25th, 2009, 04:22 PM
  3. Cookies
    By EHAM1535@aol.com in forum Technical Support
    Replies: 1
    Last Post: December 18th, 2008, 08:23 AM
  4. HELP w/ Cookies????
    By Blazerhair in forum Technical Support
    Replies: 2
    Last Post: August 12th, 2004, 10:27 PM
  5. XP cookies?
    By kramerica in forum Networking and Internet
    Replies: 13
    Last Post: July 30th, 2002, 02:08 PM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews