extacy
Member
- Jan 6, 2011
- 106
- 2
So when you have this code on your site and its your first time being there with the script, what is does is asks for your name, and then you type it in and press okay, but then nothing happends? well press F5 and it will say Welcome and the name you put in
all you do is put this on your index.html and it is perfect!
Too see how this works go too:
Credit:
me- 50% uploading to a site and some coding
mace- the other half of coding (lol)
all you do is put this on your index.html and it is perfect!
HTML:
<html>
<head>
<script type="text/javascript">
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}
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=getCookie("username");
if (username!=null && username!="")
{
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>
You must be registered for see links
it has that same thing on there!Credit:
me- 50% uploading to a site and some coding
mace- the other half of coding (lol)