JS操作Cookie
function setcookiebyaddseconds(sname,svalue,iseconds)
{
var d = new Date();
d.setTime(d.getTime() + iseconds*1000);
document.cookie=sname + "=" + svalue+" ;expires = "+d.toGMTString();
}
function setcookie(sname,svalue,iyear,imonth,iday,ihour,iminute,isecond)
{
var d = new Date();
d.setFullYear(iyear);
d.setMonth(imonth);
d.setDate(iday);
d.setHours(ihour);
d.setMinutes(iminute);
d.setSeconds(isecond);
document.cookie=sname + "=" + svalue+" ;expires = "+d.toGMTString();
}
function getcookie(sname)
{
var s=sname + "=";
begin=document.cookie.indexOf(s);
if(begin != -1)
{
begin+=s.length;
end = document.cookie.indexOf(";",begin);
if (end == -1) end = document.cookie.length;
return document.cookie.substring(begin,end);
}
else
{
return "";
}
}
function delcookie(sname)
{
document.cookie=sname + "=;expires = Thu,01-Jan-70 00:00:00 GMT";
}
{
var d = new Date();
d.setTime(d.getTime() + iseconds*1000);
document.cookie=sname + "=" + svalue+" ;expires = "+d.toGMTString();
}
function setcookie(sname,svalue,iyear,imonth,iday,ihour,iminute,isecond)
{
var d = new Date();
d.setFullYear(iyear);
d.setMonth(imonth);
d.setDate(iday);
d.setHours(ihour);
d.setMinutes(iminute);
d.setSeconds(isecond);
document.cookie=sname + "=" + svalue+" ;expires = "+d.toGMTString();
}
function getcookie(sname)
{
var s=sname + "=";
begin=document.cookie.indexOf(s);
if(begin != -1)
{
begin+=s.length;
end = document.cookie.indexOf(";",begin);
if (end == -1) end = document.cookie.length;
return document.cookie.substring(begin,end);
}
else
{
return "";
}
}
function delcookie(sname)
{
document.cookie=sname + "=;expires = Thu,01-Jan-70 00:00:00 GMT";
}
爱东东
我的各类资源收集收集网站 http://tag.iddgame.com
我的实验性技术网站 http://www.iddgame.com
我的魔兽世界网站 http://www.iddwow.com.cn