Permalink
Browse files

Initial commit

  • Loading branch information...
1 parent 0fe5580 commit a1fcb378636553bdac64270d77d5d7e0b5d3515a Irvin Ocanto committed Apr 4, 2013
Showing with 26 additions and 0 deletions.
  1. +26 −0 cookie.js
View
@@ -0,0 +1,26 @@
+var CookieHelper = {
+ create : function (name,value,days) {
+ if (days) {
+ var date = new Date();
+ date.setTime(date.getTime()+(days*24*60*60*1000));
+ var expires = "; expires="+date.toGMTString();
+ }
+ else
+ var expires = "";
+ document.cookie = name+"="+value+expires+"; path=/";
+ },
+ read : function (name) {
+ var nameEQ = name + "=";
+ var ca = document.cookie.split(';');
+ for(var i=0;i < ca.length;i++) {
+ var c = ca[i];
+ while (c.charAt(0)==' ') c = c.substring(1,c.length);
+ if (c.indexOf(nameEQ) == 0)
+ return c.substring(nameEQ.length,c.length);
+ }
+ return null;
+ },
+ erase : function (name) {
+ this.create(name,"",-1);
+ }
+}

0 comments on commit a1fcb37

Please sign in to comment.