<script language="javascript">
//写入cookie
function setCookies(name,value)
{
var Days = 30; //此 cookie 将被保存 30 天
var expdate = new Date();
expdate.setTime(expdate.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape(value) +";expire*="+ expdate.toGMTString();
}
//读取cookie
function getCookies(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}
//删除cookie
function delCookies(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie=name +"="+cval+";expire*="+**p.toGMTString();
}
//示例读取
var sCookie = getCookies("sCookie");
if (sCookie == "null"){
sCookie = "默认";
}
setTimeout("document.getElementById('cookie').innerHTML=sCookie;",1000);
</script>
<div id="cookie">loading...</div>
结束。