Analysis on basic knowledge of cookie object_in javascript operations

Source: Internet
Author: User
This article briefly introduces the methods and examples for using javascript to operate cookie objects. For more information, see Cookie object

It is a data information (Cookie data) stored in the Cookies folder on the client's hard disk in the form of a file (Cookie file ). User Data (Cookie data) in the Cookie folder ). The Cookie file is created by the accessed Web site to store session data between the client and the Web site for a long time. The Cookie data can only be read by the accessed Web site. (Cross-origin access is not allowed)

Cookie file format:

NS: Cookie.txt
IE: User Name @ domain name .txt

Javascript write Cookie

Format:
Document. cookie = "keyword = value [; expires = valid date] [;…]"
Note:
Valid Date Format: Wdy, DD-Mon-yy hh: MM: SS
Wdy/Mon: English week/month;
It also contains path, domain, and secure attributes;
20 Cookie data can be created for each Web site (domain;
Each browser can store 300 Cookie data, 4 K bytes;
The customer has disabled writing Cookie data.

Using js to operate on cookies is much more troublesome than using jsp servlet to operate on cookies.

Why can't I see the Cookie files used to store sessions in the Cookie folder?

Use two types of cookies

Persistent cookies are stored on the client's hard disk.
Session Cookie: The session Cookie is not stored on the client's hard disk, but stored in the memory of the browser process. When the browser is closed, the session Cookie is destroyed.

The Code is as follows:







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.