The Jquery.cookie.js plugin implements the cookie store of the browser, which is developed based on jquery and facilitates the use of cookies.
Jquerycookie.js's Http://plugins.jquery.com/project/cookie
1. Preparatory work
1) Since the plugin relies on jquery, first introduce the Jquey plugin on the page
2) Introducing jQuery.cookie.js on the page
2. How to use
Set cookies
/* * * Set Cookie * * The first parameter sets the cookie key * * The second parameter sets the value of the cookie * * Path to set cookie Paths * * expires sets the expiration time of the cookie if it is not set to expire when the browser is closed. */ $.cookie ("area", "002", {path: '/', expires:10});
Read cookies
/* * * Read cookies* /Console.log ($.cookie ("area"));
Delete Cookies
/* * * Delete Cookie * * */ $.cookie ("area",null, {path: '/', Expires:10});
Examples Show
1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <title></title>5 <MetaCharSet= "Utf-8">6 </Head>7 <Body>8 <Scripttype= "Text/javascript"src= "Jquery.js"></Script>9 <Scripttype= "Text/javascript"src= "Jquery.cookie.js"></Script>Ten <Scripttype= "Text/javascript"> One $(function(){ A /* - * * Set Cookies - * * The first parameter sets the key of a cookie the * * The second parameter sets the value of a cookie - * * Path to set cookie - * * Expires sets the expiration time of the cookie if it is not set to expire when the browser is closed. - */ + $.cookie (" Area","002", {path:'/', Expires:Ten}); - + /* A * * Read cookies at */ - Console.log ($.cookie (" Area")); - - /* - * * Delete cookies - ** in */ - $.cookie (" Area",NULL, {path:'/', Expires:Ten}); to }); + </Script> - </Body> the </HTML>
JQuery.cookie.js plug-in understanding and how to use