Skip to content

Instantly share code, notes, and snippets.

@yawnt
Created September 12, 2012 08:53
Show Gist options
  • Save yawnt/3705355 to your computer and use it in GitHub Desktop.
Save yawnt/3705355 to your computer and use it in GitHub Desktop.
(function(e,t,n){function i(e){return e}function s(e){return decodeURIComponent(e.replace(r," "))}var r=/\+/g,o=e.cookie=function(r,u,a){if(u!==n){a=e.extend({},o.defaults,a),u===null&&(a.expires=-1);if(typeof a.expires=="number"){var f=a.expires,l=a.expires=new Date;l.setDate(l.getDate()+f)}return u=o.json?JSON.stringify(u):String(u),t.cookie=[encodeURIComponent(r),"=",o.raw?u:encodeURIComponent(u),a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}var c=o.raw?i:s,h=t.cookie.split("; ");for(var p=0,d;d=h[p]&&h[p].split("=");p++)if(c(d.shift())===r){var v=c(d.join("="));return o.json?JSON.parse(v):v}return null};o.defaults={},e.removeCookie=function(t,n){return e.cookie(t)!==null?(e.cookie(t,null,n),!0):!1}})(jQuery,document)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment