Cookie object in JavaScript

Source: Internet
Author: User

    • Cookie Object
    • is a data message (cookie data) that is stored in the cookie folder of the client's hard disk in the form of a file (cookies file). 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)
    • The format of the cookie file:
    • NS:Cookie.txt
    • IE: User name @ domain. txt

    • JavaScript writes cookies
    • Format:
    • document.cookie= "keyword = value [; expires= Effective Date] [; ...]"
    • Note:
      • Effective date format: Wdy,dd-mon-yy HH:MM:SS
      • Wdy/mon: English Week/month;
      • Also includes path, domain, and secure attributes;
      • Each Web site (domain) can create 20 cookie data;
      • Each browser can store 300 cookie data, 4K bytes;
      • The client has no write-down cookie data.

    • It is much more troublesome to use JS to manipulate cookies than to use JSP servlet to manipulate cookies.

why can't I see the cookie file in the cookie folder that I used to hold the session ?

    • Use two types of cookies
      • Persistent cookies are stored on the client's hard disk.
      • Session Cookie: It is not stored on the client's hard disk, but is placed in the memory of the browser process, and the session cookie is destroyed when the browser is closed.

<!DOCTYPE HTML> <HTML> <Head> </Head> <Body> <Scripttype= "Text/javascript">     varToday=NewDate (); varExpireday=NewDate (); varMspermonth= -* -* -* +* to; Expireday.settime (Today.gettime ()+mspermonth); Document.cookie="name=liujl;expires="+expireday.togmtstring (); Document.writeln ("The cookie has been written to the hard drive."); Document.writeln ("The content is:"+document.cookie); Document.writeln ("Expiry time:"+expireday.togmtstring ()); </Script> </Body> </HTML>

Cookie object in JavaScript

Related Article

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.