源生态JS设置COOKIE函数及用法

function setCookie(cookiename, cookievalue, hours) {
var date = new Date();
date.setTime(date.getTime() + Number(hours) * 3600 * 1000);
document.cookie = cookiename + "=" + cookievalue + "; path=/;expires = " + date.toGMTString();

}
setCookie('tm2',suboutdate1,'1');
代码中加入这个函数,就可以设置cookie,无需用jquery-cookie,方便

你可能感兴趣的:(源生态JS设置COOKIE函数及用法)