Filco Majestouch 넌클릭 영문 계절이 바뀝니다.
Oct 29

var Cookies={set:function(n,v,d){var g="";if(d!=undefined){var f=new Date();f.setTime(f.getTime()+(d*24*60*60*1000));g="; expires="+f.toGMTString();};document.cookie=escape(n)+"="+escape(v||'')+g;},get:function(n){var a=n+"=";var r=null;document.cookie.split(';').each(function(s){while(s.charAt(0)==' ')s=s.substring(1,s.length);if(s.indexOf(a)==0)r=s.substring(a.length,s.length);});return r;},remove:function(n){this.set(n,'',-1);return this.get(n)||true;}};

RequireMent
Prototype Framework (http://www.prototypejs.org)

Usage
Cookies.set(name, value, expired date);
Cookies.get(name);
Cookies.remove(name);

4 Responses to “JavaScript - Prototype Based Cookie Object”

  1. DyNast Says:

    우왕…. 뭔말인지 모르겟다능.. ㅠㅠ 자바스크립트 어려움..

  2. defel Says:

    Thanks! Nice and powerfull Snippet :)

    ps.: I added a `return unescape(r);` to the get-Function .. because the cookie-content get escaped when setted.

  3. ecstatic Says:

    Thanks to coming my blog :]

  4. Yaz Okulu Says:

    does anyone knows if there is any other information about this subject in other languages?

Leave a Reply