js cookie删除,增加,修改
function getcookie(n) {
var dc = "; "+document.cookie+"; ";
var coo = dc.indexOf("; "+n+"=");
if (coo!=-1){
var s = dc.substring(coo+n.length+3,dc.length);
return unescape(s.substring(0, s.indexOf("; ")));
}else{
return "";
}
}
function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {
var expires = new Date();
seconds = seconds ? seconds : 24*60*60*1000;
expires.setTime(expires.getTime() + seconds);
expires = is_Moz ? expires.toUTCString() : expires.toGMTString();
document.cookie = escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires : '')
+ (path ? '; path=' + path : '/')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
}
function deletecookie(cookieName,path, domain){
var exp = new Date();
exp.setTime(exp.getTime() - 10000);
var cval=getcookie(cookieName);
if(cval!=null)
{
document.cookie = escape(cookieName) + '=aa'
+ ('; expires=' + exp.toGMTString())
+ (path ? '; path=' + path : '/')
+ (domain ? '; domain=' + domain : '')
}
}