<script type = "text/javascript">
var expDate = new Date();
expDate.setTime(expDate.getTime()+365*24*60*60*1000); // one year ahead
function setCookie(isName,isValue,dExpires) {
document.cookie = isName + "=" + isValue + ";expires=" + dExpires.toGMTString() + "path=/";
}
function getCookie(isName){
cookieStr = document.cookie;
startSlice = cookieStr.indexOf(isName+"=");
if (startSlice == -1) {return false}
endSlice = cookieStr.indexOf(";",startSlice+1)
if (endSlice == -1){endSlice = cookieStr.length}
isData = cookieStr.substring(startSlice,endSlice)
isValue = isData.substring(isData.indexOf("=")+1,isData.length);
return isValue;
}
function dispCookie(isName) {
nValue = getCookie(isName);
alert(nValue);
}
function deleteCookie(isName){
if (getCookie(isName)){
document.cookie = isName + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
</script>
</head>
<body>
<input type = "button" value = 'Set Cookie' onclick = "setCookie('anyName','Hello',expDate)">
<br><br>
<input type = "button" value='Delete Cookie' onclick="deleteCookie('anyName')">
<br><br>
<input type = "button" value = 'Read Cookie' onclick = "dispCookie('anyName')">
</body>
"To get back my youth I would do anything in the world, except take exercise, get up early, or be respectable." - Oscar Wilde (Irish Poet, Novelist, Dramatist and Critic, 1854-1900)