jquery Read-Write cookie

Source: Internet
Author: User
Tags set cookie

The jquery cookie requires the script file as follows: Jquery.cookie = function (name, value, options) {if (typeof value! = ' undefined ') {options = Optio NS | |   {};    if (value = = = NULL) {value = ';    Options = $.extend ({}, Options);   Options.expires =-1;   } var expires = ';    if (Options.expires && (typeof options.expires = = ' Number ' | | options.expires.toUTCString)) {var date;     if (typeof options.expires = = ' number ') {date = new date ();    Date.settime (Date.gettime () + (Options.expires * 24 * 60 * 60 * 1000));    } else {date = Options.expires; } expires = ';   Expires= ' + date.toutcstring (); } var path = Options.path? ‘;   Path= ' + (Options.path): '; var domain = Options.domain? ‘;   Domain= ' + (options.domain): '; var secure = options.secure? ‘;   Secure ': '; Document.cookie = [name, ' = ', encodeURIComponent (value), expires, path, domain, Secure].join (");}   else {var cookievalue = null; if (document.cookie && document.cookie! = ") {var cookies= Document.cookie.split (';');     for (var i = 0; i < cookies.length; i++) {var cookie = Jquery.trim (Cookies[i]); if (cookie.substring (0, name.length + 1) = = (name + ' = ')) {cookievalue = decodeURIComponent (cookie.substring (name.le      Ngth + 1));     Break }}}; return cookievalue;}};page Call just introduce this file$.cookie ("name"); The cookie value is $.cookie ("name", "value") based on the cookie name, and/or set the cookie name, value $.cookie ("name", "value", "{expires:7}"); Set cookie name, value, life cycle and other attributes $.cookie ("name", null); Remove cookies based on cookie name

jquery Read-Write 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.