note the Cookie Path setting. If path: '/' is not set, the path is automatically set according to the directory. For example: http://www.xxx.com/user/, pathwill be set to '/user']
$. Extend ({/** 1. set the cookie value and set the value of the name variable to value example $. cookie ('name', 'value'); 2. create a cookie, including the Domain Name of the validity period and other example $. cookie ('name', 'value', {expires: 7, path: '/', domain: 'jquery. com ', secure: true}); 3. create cookieexample $. cookie ('name', 'value'); 4. delete A cookieexample $. cookie ('name', null); 5. get a cookie (name) value to myvarvar account = $. cookie ('name'); **/cookiehelper: function (name, value, options) {If (typeo F value! = 'Undefined') {// name and value given, set cookie Options = options |{}; if (value = NULL) {value = ''; 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 {d Ate = options. expires;} expires = '; expires =' + date. toutcstring (); // use expires attribute, Max-age is not supported by IE} 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 {// only name given, get Cookie 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]); // does this cookie string begin with the name we want? If (cookie. substring (0, name. length + 1) = (name + '=') {cookievalue = decodeuricomponent (cookie. substring (name. length + 1); break ;}}return cookievalue ;}}});