1, the use of grammar
| The code is as follows |
Copy Code |
| $.cookie (' The_cookie ', ' the_value '); |
Set the value of the cookie/create a cookie. The former is the key and the latter is the value.
| The code is as follows |
Copy Code |
| $.cookie (' The_cookie ', ' The_value ', {expires:7, path: '/', Domain: ' jquery.com ', secure:true}); |
Create a new cookie, including expiration, path, domain name, etc.
| The code is as follows |
Copy Code |
| $.cookie (' The_cookie ', null); |
Delete Cookies
| The code is as follows |
Copy Code |
| var myval=$.cookie (' The_cookie '); |
Get the value of a cookie
2, using the example
After a successful login, you can save the user name in a cookie.
| The code is as follows |
Copy Code |
| $.cookie (' UserName ', $ ("#txtUsername"). Val ();//txtusername to TextBox control |
Summarize:
| code is as follows |
copy code |
| $.cookie (' The_cookie '); Read Cookies $.cookie (' The_cookie ', ' the_value ');//Store Cookies $.cookie (' The_cookie ', ' The_value ', {expires:7}) ; Stores a cookie with a duration of 7 days $.cookie (' The_cookie ', ', {Expires:-1});//delete cookie |