We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
document.cookie = 'user=blue'; document.cookie = 'pass=blue';//不会被覆盖,只会被添加 //如果未设置过期时间,浏览器关闭只会,cookie便会过期 var oDate = new Date(); oDate.setDate(oDate.getDate()+14);//代表14天只会过期 document.cookie = 'user=blue;expires='+oDate;//设置过期时间
function setCookie(name,value,iDay){ var oDate = new Date(); oDate.setDate(oDate.getDate()+iDay); document.cookie =name+'='+value+';expires='+oDate; }
function getCookie(name){ var arr = ducument.cookie.split('; ');//空格不能少 //cookie中的数据以'; '进行分割 for(var i=0;i<arr.length;i++){ var arr2 = arr[i].split('=');//数据形式一般为user='www' if(arr2[0]===name){ return arr2[1]; }else{ return ''; } } }
function removeCookie(){ setCookie(name,1,-1); //setcookie(名字,值,多少天后过期) }
End
by wind-jyf
The text was updated successfully, but these errors were encountered:
No branches or pull requests
cookie
什么是cookie?
如何在JS中使用cookie
封装cookie
从cookie中读取数据
删除cookie
End
by wind-jyf
The text was updated successfully, but these errors were encountered: