1. 程式人生 > >js設定cookie

js設定cookie

//寫cookies
function setCookie(name, value, time,path,domain,secure) {
var strsec = getsec(time);
var exp = new Date();
exp.setTime(exp.getTime() + strsec * 1);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+ (path ? '; path=' + path : '/')+ (domain ? '; domain=' + domain : '')+ (secure ? '; secure' : '');
}