Actions in Jquery.cookie (cross-domain sharing)

Source: Internet
Author: User

actions in Jquery.cookie:

Jquery.cookie.js is a jquery based plugin, click Download.

Create a session cookie:

$.cookie (' cookiename ', ' cookievalue ');

Note: When no cookie time is specified, the cookie that is created is known as the session cookie by default to the user's browser shutdown.

To create a persistent cookie:

$.cookie (' cookiename ', ' Cookievalue ', {expires:7});

Note: When the time is specified, it is called a persistent cookie and the valid time is days.

Create a cookie that is persistent and with a valid path:

$.cookie (' cookiename ', ' Cookievalue ', {expires:7,path: '/'});

Note: If you do not set a valid path, by default, only the path to read the Cookie,cookie on the cookie Settings current page is used to set up a top-level directory that can read cookies.

Create a cookie that is persistent and with a valid path and domain name:

$.cookie (' cookiename ', ' Cookievalue ', {expires:7,path: '/', Domain: ' chuhoo.com ', secure:false,raw:false});

Note: domain: Create the name of the Web page owned by the cookie; secure: Default is False, if the transport protocol for True,cookie is Https;raw: Default is False, Automatic encoding and decoding when reading and writing (using encodeURIComponent encoding, decoding using decodeuricomponent), turn off this feature, set to true.

Get Cookies:

$.cookie (' cookiename ');   Returns Cookievalue if present, otherwise null is returned.

To delete a cookie:

$.cookie (' cookiename ', null);

Note: If you want to delete a cookie with a valid path, the following:

$.cookie (' CookieName ', Null,{path: '/'});

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.