21
5
内容纲要

Js实现Cookie操作,JavaScript的Cookie操作,源代码
在JavaScript中如何实现Cookie操作呢,下面给出源代码实现:

function SetCookie(name,value,days)
{
if(days == null) days = 30;
var exp = new Date;
exp.setTime(exp.getTime() + days*24*60*60*1000);
document.cookie = name + "="+ escape(value) +";expires="+ exp.toGMTString() + "; path=/";
}
function GetCookie(name)
{
var arr = document.cookie.match(new RegExp("(^ )"+name+"=([^;]*)(;$)"));
if(arr != null) return unescape(arr[2]); return null;
}

声明: 本文采用 BY-NC-SA 协议进行授权. 未标注“转”的文章均为原创,转载请注明转自: Js实现Cookie操作,JavaScript的Cookie操作,源代码

公告栏

欢迎大家来到我的博客,我是dodoro,希望我的博客能给你带来帮助。