Cookie operation is a function we often use in web development. In the past, we usually implemented it through javascript. The following jquery plug-in is specially used for cookie operations
, including adding, clearing, reading cookies...
You can download it from the homepage of this plug-in: http://jquery.com/
When in After the jquery file and the plug-in file are referenced in the page, you can perform the following operations:
Set cookie
Set a cookie with name blog and value css9.net:
$.cookie("blog", "css9.net"); Set a cookie with name blog and value css9. net cookie, and set the expiration time (expires attribute) to 7 days:
$.cookie("blog", "css9.net", { expires: 7 }); Set a name to blog and a value to css9. net cookie, set the expiration time (expires attribute) to 7 days, the same as
Set the path attribute of the cookie to "/admin"
$.cookie("blog", "css9.net", { path: '/admin', expires: 7 }); Read Cookie:
Read the cookie value named blog:
alert( $.cookie("blog") ); delete cookie:
$.cookie("example", null);
Downloaded js file There is a more detailed explanation in