Revision: 66086
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 12, 2014 10:01 by deanhouseholder
Initial Code
function setCookie(c_name,c_value,c_expiredays,c_path,c_domain) {
var c_exdate=new Date();
c_exdate.setDate(c_exdate.getDate()+c_expiredays);
document.cookie=c_name+ "=" +escape(c_value)+((c_expiredays==null) ? "" : ";expires="+c_exdate.toUTCString()) +"; path="+ c_path +"; domain="+ c_domain;
}
function getCookie(tag) {
var value = null
var myCookie = document.cookie + ";"
var findTag = tag + "="
var endPos
if (myCookie.length > 0) {
var beginPos = myCookie.indexOf(findTag)
if (beginPos != -1) {
beginPos = beginPos + findTag.length
endPos = myCookie.indexOf(";",beginPos)
if (endPos == -1)
endPos = myCookie.length
value = unescape(myCookie.substring(beginPos,endPos))
}
}
return value
}
function deleteCookie(cookie) {
var yesterday = 24 * 60 * 60 * 1000
var expireDate = new Date()
expireDate.setTime (expireDate.getTime() - yesterday)
document.cookie =cookie + "=" + escape("nothing") + ";" + "expires" + "=" + expireDate.toGMTString()
}
Initial URL
Initial Description
Simple functions to add, fetch or delete cookies in the browser via JavaScript.
Initial Title
JavaScript Cookie Functions
Initial Tags
javascript
Initial Language
JavaScript