Previously thought to get the cookie method encapsulated in the jquery package ... Did not expect to have to separate under Jquery.cookie.js plug-in, not too easy to find, backup a copy:
/*! * JQuery Cookie Plugin v1.4.1 * Https://github.com/carhartl/jquery-cookie * * Copyright Klaus Hartl * released under The MIT license * * (function (Factory) {if (typeof define = = = ' function ' && define.amd) {//Amddefine ([' jquery '], F actory);} else if (typeof exports = = = ' object ') {//Commonjsfactory (Require (' jquery '));} else {//Browser globalsfactory (jquery);}} (function ($) {var pluses =/\+/g;function Encode (s) {return config.raw? s:encodeuricomponent (s);} function decode (s) {return config.raw? s:decodeuricomponent (s);} function Stringifycookievalue (value) {return encode (Config.json? Json.stringify (value): String (value));} function Parsecookievalue (s) {if (S.indexof (' "') = = = 0) {//This is a quoted cookie as according to RFC2068, UNESCAPE...S = S.slice (1,-1). replace (/\\ "/g, '" '). Replace (/\\\\/g, ' \ \ ');} try {//Replace server-side written pluses with spaces.//if we can ' t decode the cookie, ignore it, it ' s unusable.//if we Can ' t parse the cookie, ignore it, it ' sUNUSABLE.S = decodeURIComponent (S.replace (pluses, ")); return Config.json? Json.parse (s): s;} catch (e) {}}function read (s, converter) {var value = Config.raw? S:parsecookievalue (s); return $.isfunction (Converter)? Converter (value): value;} var config = $.cookie = function (key, value, options) {//Writeif (value!== undefined &&!$.isfunction (value)) { Options = $.extend ({}, Config.defaults, Options), if (typeof options.expires = = = ' number ') {var days = options.expires, t = Options.expires = new Date (); T.settime (+t + days * 864e+5);} return (Document.cookie = [Encode (key), ' = ', Stringifycookievalue (value), Options.expires? ‘; Expires= ' + options.expires.toUTCString (): ',//Use expires attribute, Max-age are not supported by Ieoptions.path? ‘; Path= ' + options.path: ', Options.domain? ‘; Domain= ' + options.domain: ', options.secure? ‘; Secure ': '].join ('));} Readvar result = key? Undefined: {};//to prevent the ' for loop ' in the first place assign a empty ARray//in case there is no cookies at all. Also prevents odd result when//calling $.cookie (). var cookies = Document.cookie? Document.cookie.split ('; '): [];for (var i = 0, L = cookies.length; i < L; i++) {var parts = cookies[i].split (' = '); var name = decode (parts.shif T ()); var cookie = parts.join (' = '); if (key && key = = = name) {//If second argument (value) is a function it s a con Verter...result = Read (cookie, value); Prevent storing a cookie that we couldn ' t Decode.if (!key && (cookie = read (cookie))!== undefined) {Result[nam E] = cookie;}} return result;}; Config.defaults = {};$.removecookie = function (key, options) {if ($.cookie (key) = = = undefined) {return false;} Must not alter options, thus extending a fresh object...$.cookie (key, ', $.extend ({}, Options, {Expires:-1}); retur n!$.cookie (key);});
jquery Get Cookie