Cookie object:
is a user data information (cookie data) stored in the cookie folder of the client's hard disk in the form of a file (cookies file). The cookie file is established by the Web site visited to hold the session data between the client and the Web site for a long time, and the cookie data is only allowed to be read by the Web site visited.
Storing Cookies
<script> function Savecookie (cname,cvalue,exdays) {var d = new Date (); D.settime (D.gettime () +exdays*24*60*60*1000); var exprices = "exprices=" + d.togmtstring (); Document.cookie = cname+ "=" +cvalue+ ";" +exprices; }
read Cookies
function readcookie (CNAME) { var name = cname+ "="; var ck =document.cookie.split (";"); for (var n=0;n<ck.length;n++) { var c=ck[n].trim (); if (C.indexof ("name") ==0) { return c.substr (name.length, c.length); } } }
Applications in HTML
<input type= "button" value= "Storage" <input type= "button" value= "read" onclick= "alert (Readcookie (' name '))" >
This article is h5edu official HTML5 Training Course, Main introduction:JavaScript Intensive Tutorial --cookie Object
JavaScript Intensive Tutorial-cookie Object