Cookies are a very practical function that can determine a certain status and are highly used in projects
Function setCookie(name,value)
{
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() Days*24*60*60*1000);
document.cookie = name "=" escape (value) ";expires=" exp.toGMTString();
var strsec = getsec(time);
var exp = new Date();
exp.setTime(exp.getTime() strsec*1);
document.cookie = name "=" escape (value) ";expires=" exp.toGMTString();
}
//Read cookies
Function getCookie(name)
{
var arr,reg=new RegExp("(^| )" name "=([^;]*)(;|$)");
If(arr=document.cookie.match(reg))
Return (unescape(arr[2]));
else
return null;
}
//Delete cookies
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();
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn