Cookie Object
is a data information (cookie data) stored in a cookie folder on the client's hard disk in the form of a file (cookies file). The User data information (cookie data) in the cookie folder. 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. (Cross-domain access is not allowed)
Format of cookie file:
NS:Cookie.txt
IE: User name @ domain. txt
JavaScript Write Cookie
Format:
document.cookie= "keyword = value [; expires= Effective Date] [; ...]"
Note:
Valid date format: Wdy,dd-mon-yy HH:MM:SS
Wdy/mon: English Week/month;
Also contains path, domain, secure attributes;
Each Web site (domain) can create 20 cookie data;
Each browser can store 300 cookie data, 4K bytes;
The customer has a write that prohibits cookie data.
Using JS to manipulate cookies is much more troublesome than using a JSP servlet to manipulate cookies.
Why can't I see the cookie file that holds the session in the cookie folder?
Use two types of cookies
Persistent cookies, which are stored on the client's hard disk.
Session Cookie: It is not stored on the client's hard disk, but in the memory of the browser process, and the session cookie is destroyed when the browser closes.
Copy Code code as follows:
<! DOCTYPE html>
<body>
<script type= "Text/javascript" >
var today=new Date ();
var expireday=new Date ();
var mspermonth=24*60*60*1000*31;
Expireday.settime (Today.gettime () +mspermonth);
Document.cookie= "name=liujl;expires=" +expireday.togmtstring ();
Document.writeln ("Cookies have been written to the hard disk");
Document.writeln ("Content is:" +document.cookie);
Document.writeln ("Expired Time:" +expireday.togmtstring ());
</script>
</body>