Let's start by introducing basic information about cookies:
The cookie is in the domain, it must be placed in the environment of the server, but the capacity of the cookie is small, only 4kb, and also is not safe, and the name of the shares of the cookie is the same, will modify or overwrite the original value, if the name is different, will add a cookie;
And then I'll talk to you about getting cookies:
The format in which the cookie is obtained is a string;
A cookie in the parent seed, which can be obtained by a child, or a cookie under a child, which is not obtained by the parent;
There is the path of the cookie: can be set, is generally set to the '/' root directory;
Okay, here's what I've encapsulated. Three usage functions of cookies;
Document.cookie='ac=123'; //species undera cookie;function Setcookie (name,value,iday) {if(iday) {varOdate=NewDate (); Odate.setdate (Odate.getdate ()+iday); Document.cookie=name+'='+value+';p ath=/;expires='+odate; }Else{Document.cookie=name+'='+value+';p ath=/'; }} Setcookie ('ASD','123'); Setcookie ('qwe','TD',3); //get a cookie;function GetCookie (name) {varArr=document.cookie.split ('; '); for(varI=0; i<arr.length;i++){ varTmp=arr[i].split ('='); if(name==tmp[0]){ returntmp[1]; } } return "'; } //delete a cookie;function Removecookie (name) {Setcookie (name,'ASD',-1)} removecookie ('ASD')
What is wrong to write the place, I hope you leave a message guidance, thank you O (∩_∩) o Thank you!!!
Cookie settings, acquisition, and deletion