Chinaunix首页 | 论坛 | 博客
  • 博客访问: 163239
  • 博文数量: 43
  • 博客积分: 95
  • 博客等级: 民兵
  • 技术积分: 215
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-24 17:23
文章分类

全部博文(43)

文章存档

2016年(1)

2015年(5)

2014年(10)

2013年(24)

2012年(3)

我的朋友

分类: JavaScript

2014-06-18 14:02:10

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
        ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
    f (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        { 
            c_start=c_start + c_name.length+1 ;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1)
                 c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
    return "";
}
function delCookie(c_name)
{
    setCookie(c_name,“”,-1000)
}
function delAllCookie()
{
    var strCookie=document.cookie;
    var arrCookie=strCookie.split("; ");
    for(var i=0;i     {
        var arr=arrCookie[i].split("=");
        if(arr.length>0)
            delCookie(arr[0]);
    }
}


php设置cookie
php删除cookie
阅读(1062) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~