"JQ" plugin-cache Jquery.cookie.js

Source: Internet
Author: User

jquery.cookie.js Plugin Lightweight cookie Management

1°:http://plugins.jquery.com/cookie/

2° Introduction Method: (based on jquery)

<script type= "Text/javascript" src= "Js/jquery-1.6.2.min.js" ></script>

<script type= "Text/javascript" src= "Js/jquery.cookie.js" ></script>

3° Invocation Mode:

1)//New Cookie:

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

Note: If you do not set a cookie's validity period, the cookie is called "Session cookie" by default until the browser is closed.

2)//Create a cookie and set the validity time to 7 days:

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

3)//Create a cookie and set a valid path for the cookie:

$.cookie (' cookiename ', ' Cookievalue ', {

Expires:7,

Path: '/'

});

Note: By default, only the Web page that sets the cookie can read the cookie. If you want a page to read a cookie set by another page, you must set the path to the cookie. The path to the cookie is used to set the top-level directory to read cookies. Set this path to the root of your Web site so that all Web pages can read cookies to each other (typically not set up to prevent collisions).

4)//Read cookies:

$.cookie (' cookiename ');//returns ' Cookievalue ' if the cookie exists; returns null if the cookie does not exist

5)//delete cookie: Set the value of Ncookie to null

$.cookie (' The_cookie ', null);

6)//parameter optional

$.cookie (' The_cookie ', ' The_value ', {

Expires:7,

Path: '/',

Domain: ' jquery.com ',

Secure:true

});

Note:

Expires: (number| date); When an integer is set, the unit is days; You can also set a Date object as the expiration date of the cookie;

Path: (String) creates the page path for the cookie;

Domain: (String) The domain name of the page that created the cookie;

Secure: (Booblean) If set to true, then the transfer of this cookie will require a security protocol such as: HTTPS;

"JQ" plugin-cache Jquery.cookie.js

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.