javascript cookie

function setCookie(cname,cvalue)
{
    document.cookie=cname+"="+cvalue;
}
 
function getCookie(cname)
{
    var cookie=document.cookie;
    var beg=cookie.indexOf(cname+"=");
    if(beg<0) return "";
    var end=cookie.substr(beg).indexOf(';');
    if(end<0) end=cookie.length;
    else end=beg+end;
    return cookie.substring(beg+cname.length+1,end);
}

 

posted @ 2017-06-08 00:14  cdongyang  阅读(118)  评论(0编辑  收藏  举报