Home > Web Front-end > JS Tutorial > Description of how to use js (jquery) to operate cookies_jquery

Description of how to use js (jquery) to operate cookies_jquery

WBOY
Release: 2016-05-16 17:08:09
Original
1104 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template