Pure JavaScript manipulation cookies only need to remember two points:
Remove all cookies in the Cookie:document.cookie that contain a domain name, stored in Prop1=value1;prop2=value2...propn=valuen form, So it takes two times to find an attribute to use the String.IndexOf method.
Stores cookie:document.cookie=prop=value;expires= (date) date. togmtstring (); Yes, one is the value, one is the expiry time!
Of course, it is necessary to note that the Date object in JS, see the following sentence
var d=New Date (); Console.log (d);d. Setminutes (D.getminutes ()+60); Console.log (d);
The output is
Date {Wed Oct 11:10:30 gmt+0800} Date {Wed Oct 12:10:30 gmt+0800} Setminutes will automatically forward the bit, so you can control the expiry time in this way, you can setseconds by seconds, by Setminutes, by the hour sethours, setdate by day, setmonth by month, Year setFullYear and so on. destroying a cookie simply sets its expiry time to a past time. HTML5 provides two new ways for clients to store data:
sessionstorage: Data storage for a sessionlocalstorage: Data storage with no time limitPreviously, these were all done by cookies. However, cookies are not suitable for storing large amounts of data because they are passed by each request to the server, which makes the cookie slow and inefficient. for different sites, the data is stored in different regions, and a Web site can only access its own data. Access to it is also very simpleSessionstorage.propname&localstorage.propname, directly the name as a property of Sessionstorage and Localstorage, the corresponding value as the value of the property, you can! So easy!
Web Storage---cookie,localstorage,sessionstorage