<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
</head>
<body style=”font-size:12px;font-family:Arial, Helvetica, sans-serif;”>
Cookie Value
<input id=”c-value” type=”text” />
<br />
<br />
<input type=”button” value=”create” onclick=”create()” />
<input type=”button” value=”update” onclick=”update()” />
<input type=”button” value=”remove” onclick=”remove()” />
<input type=”button” value=”check” onclick=”check()” />
<script language=”javascript”>
function create()
{
document.cookie =’Cookie_value = ‘+ document.getElementById(“c-value”).value +’; path=/’;
}
function remove()
{
document.cookie =’Cookie_value = ‘+ document.getElementById(“c-value”).value +’;expires=Fri, 3 Aug 2001 20:47:11 UTC; path=/’; // expires=old date;
}
function update()
{
document.cookie =’Cookie_value = ‘+ document.getElementById(“c-value”).value +’;path=/’; // expires=old date;
}
function check()
{
if((document.cookie).indexOf(“Cookie_value=”)>=0)
{
var t=document.cookie.split(‘;’);
alert((t[t.length - 1].split(‘=’))[(t[t.length - 1].split(‘=’)).length – 1]);
}
else
alert(“No Cookie”);
}
</script>
</body>
</html>
Cookie in JavaScript
In Uncategorized on July 6, 2010 at 12:57 pm
Advertisement