Introduction to Jquery-cookieplug.js Cookie usage

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.