function SetCookie(name,value,expiry,path,domain,secure){
var NameString = name + "=" + value;
var ExpiryString = (expiry == null) ? "" : " ;expires = "+ expiry.toGMTString();
var PathString = (path == null) ? "" : " ;path = "+ path;
var DomainString = (path == null) ? "" : " ;domain = "+ domain;
var SecureString = (secure) ?";secure" :"";
document.cookie = NameString + ExpiryString + PathString + DomainString + SecureString;
}
function GetCookie(name) {
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}
function DelCookie(name){
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
2 則留言:
you saved me.
many scripts not actually delete cookie, your code works, thank you!
Thank you!
張貼留言