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