Thread: Cookies with HTML
-
February 14th, 2011, 02:58 PM #1Junior 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?
-
February 15th, 2011, 02:13 AM #2Member
- 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.
-
February 15th, 2011, 02:14 AM #3Member
- 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
-
Export excel --> html - How to clean html?
By BITM@D in forum Applications and Operating SystemsReplies: 21Last Post: February 15th, 2010, 10:21 AM -
Cookies
By Germain in forum Technical SupportReplies: 9Last Post: April 25th, 2009, 04:22 PM -
Cookies
By EHAM1535@aol.com in forum Technical SupportReplies: 1Last Post: December 18th, 2008, 08:23 AM -
HELP w/ Cookies????
By Blazerhair in forum Technical SupportReplies: 2Last Post: August 12th, 2004, 10:27 PM -
XP cookies?
By kramerica in forum Networking and InternetReplies: 13Last Post: July 30th, 2002, 02:08 PM



LinkBack URL
About LinkBacks



Reply With Quote

We have an outrageous system of executive compensation in his country. If the huge salaries topped by even huger (is there such a word? :heh:) were the outcome of free market competition, I would...
Who Pays Corporate Income Taxes ?