Cookie Objects
It is a type of data information (Cookie data) stored in the Cookies folder of the client's hard disk in the form of a file (Cookie file). User data information (Cookie data) in the cookie folder. The cookie file is created by the visited Web site to save 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 visited Web site. (Cross-domain access is not allowed)
Cookie file format:
NS:Cookie.txt
javascript write cookies
Format:
document.cookie="Keyword=value[;expires=valid date][;…]”
Remark:
Valid date format: Wdy, DD-Mon-YY HH:MM: SS
Wdy/Mon: English week/month;
It also contains path, domain, and secure attributes;
Each Web site (domain) can create 20 cookie data;
Each browser can store 300 cookie data, 4K bytes;
Customers prohibit writing of cookie data.
Using js to operate cookies is much more troublesome than using jsp servlets to operate cookies
Why can't I see the cookie file used to store the Session in the Cookie folder?
Use two types of cookies
Persistence cookies will be stored on the client's hard drive.
Session Cookie: It is not stored on the client's hard disk, but is placed in the memory of the browser process. When the browser is closed, the session cookie is destroyed.
The code copy is as follows:
<!DOCTYPE html>
<html>
<head>
</head>
<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("cookie has been written to the hard drive");
document.writeln("Content is:"+document.cookie);
document.writeln("Expiration time:"+expireDay.toGMTString());
</script>
</body>
</html>