标签:cookies mat .com set UI function val value path
/**setCookie函数需要参数,name属性 value值 time时间**/
function setCookie(name,value,time){
var date = new Date();
date.setTime(date.getTime() + time*1000);
document.cookie = "" + name + ‘=‘ + value + "; expires=" + date.toGMTString() + "; path=/; domain=360duohui.com";
}
// DO : JS获取cookies
/**getCookie函数需要参数,name属性**/
function getCookie(name){
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr = document.cookie.match(reg))
return unescape(arr[2])
else
return null
}
/**delCookie函数需要参数,name属性**/
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() + "; path=/; domain=360duohui.com";
}
jS获取,设置,删除cookie
标签:cookies mat .com set UI function val value path
原文地址:http://www.cnblogs.com/hfgb/p/7115840.html