Cookie usage in jquery

Source: Internet
Author: User

Session Cookie Dialog Cache

Create a Dialog cache

$.cookie (' name ', ' value ');

Set the expiration time and whether the global

$.cookie (' name ', ' value ', {expiring:7,path: '/'});

Read cookies

$.cookie (); ----Read all available cookies

$.cookie (' name ')----Gets the cookie of name, if there is a return cookie value, there is no return undefined

Delete Cookies

$.removecookie (' name ')----Delete successfully returns TRUE if the deletion is a nonexistent cookie that returns false

If you set the value of a parameter in a cookie, you must include the parameter value when deleting

The different parameters represent different cookies.

Configuration

Raw

$.cookie.raw=true; ----is equivalent to using the Encodeuricomponent/decodeuricomponent

Json

$.cookie.json=true; ----whether to use json.stringify and Json.parse

Default Properties

Expiring:365 defines the life of a cookie if you do not set a cookie will become a dialog cache

Path: '/'----default is the path of the current page where the cookie was created

Domain: ' example.com '----default is the domain name of the current page where the cookie was created

Secure:true----Default is False, if true, use HTTPS to access

Conversion functions

$.cookie (' foo ', ' 42 ');

$.cookie (' foo ', number)----reads the Foo value and outputs the Read value in number form

$.cookie (' foo ', unescape)----do not use conversion functions

Cookie usage in jquery

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.