Skip to content

Instantly share code, notes, and snippets.

@apueee
Forked from ajaxray/cookies.min.js
Created June 28, 2013 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apueee/5886199 to your computer and use it in GitHub Desktop.
Save apueee/5886199 to your computer and use it in GitHub Desktop.
/**
* Cookies - [compressed] A small class to manipulate cookies from javascript
* Uncompressed version: https://gist.github.com/gists/4139367
*/
window.Cookies={set:function(e,t,n,r){if(n){var i=new Date;i.setTime(i.getTime()+n*24*60*60*1e3);var s="; expires="+i.toGMTString()}else var s="";var o=r||"/";document.cookie=e+"="+t+s+"; path="+o},get:function(e){var t=e+"=";var n=document.cookie.split(";");for(var r=0;r<n.length;r++){var i=n[r];while(i.charAt(0)==" ")i=i.substring(1,i.length);if(i.indexOf(t)==0)return i.substring(t.length,i.length)}return null},"delete":function(e){this.set(e,"",-1)}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment