'Cookie'에 해당되는 글 3건

  1. 2011.11.30 JavaScript Cookie 맛보기.
  2. 2009.03.12 네이버 vs 야후코리아 비로그인 쿠키값
  3. 2009.03.11 browser cookie restriction

JavaScript Cookie 맛보기.

ITWeb/개발일반 2011.11.30 14:40
Browser 에서 Cookie 를 다루는 것은 매우 오래된 기술이죠.
그래서 맛보기 작성해 봅니다.
기억을 새록 새록 ㅎㅎ

- 단일 Domain 에대한 쿠키 count 와 length 제한이 있습니다. 이전 글 참고하세요.


[Session vs Persistent Cookie]

- Session Cookie
Temporary Cookie 라고도 합니다.
말 그대로 임시쿠키 입니다.
브라우저가 살아 있는 동안만 유지되는 쿠키로 expire date 이 없기 때문에 브라우저를 닫으면 바로 쿠키는 사라집니다.

- Persistent Cookie 
세션쿠키와 다르게 브라우저가 닫혀도 쿠키가 유지 되는 쿠키 입니다.
즉, expire date 을 설정해 주기 때문에 그 기간 동안 쿠키는 유지 되며, 임의 삭제를 하지 않는 이상 유지됩니다.
이 쿠키는 expire 되기 전까지 쿠키 file 에 쓰여져서 저장됩니다.


<!DOCTYPE html>



<title>JavaScript Cookie</title>

<script type="text/javascript">


var COOKIE = {

set:function (n,v,e,t) {

var expireDate = new Date();

var cookieValue;

switch ( t ) {

case 'day' :

expireDate.setDate(expireDate.getDate() + e);


case 'hour' :

expireDate.setTime(expireDate.getTime() + (e*60*60*1000));


default :

expireDate.setDate(expireDate.getDate() + e);


if ( e ) {

cookieValue = escape(v)  + '; expires='+expireDate.toGMTString();

} else {

cookieValue = escape(v) ;


document.cookie = n + '=' + cookieValue + '; path=/';


get:function(n) {

var cookies = document.cookie.split(';');

var i, key, val, size, idx;

size = cookies.length;

for ( i=0; i<size; i++ ) {

idx =  cookies[i].indexOf('=');

key = cookies[i].substr(0, idx);

val = cookies[i].substr(idx+1);

key = key.replace(/^\s+|\s+$/g,"");

if ( key == n ) {

return unescape(val);




del:function(n) {




function testGet() {

var val = COOKIE.get('DUID');



function testDel() {







<body style='margin:0px; padding:0px;' topmargin='0px'  leftmargin='0px' marginheight='0px' marginwidth='0px'>

<button onclick="COOKIE.set('DUID', '123456789', 365);">set cookie</button>

<button onclick="testGet();">get cookie</button>

<button onclick="testDel();">del cookie</button>



※ 기본 code base 는 위 두 사이트를 바탕으로 작성한 것입니다.
크리에이티브 커먼즈 라이선스
Creative Commons License
tags : Cookie, javascript
Trackback 0 : Comment 0

네이버 vs 야후코리아 비로그인 쿠키값

ITWeb/스크랩 2009.03.12 10:16
비로그인 사용자들의 posting 에 대해 고민 하고있다가 기냥 한번 포털의 쿠키에 어떤 값들이 있는지 궁금해서..
뭐.. 별 의미없이 값을 뽑아 봤다는거. ^^;

- 네이버 비로그인 상태 쿠키값
npic=jUr+cUCGVKdjpbJwd62X0RqpRHJfWNpzHzzA0DL673pOET0AAFlM2timsR6wJPjQCA==; nsr_acl=1; NB=GA2DEOBSGQ3TEOJV; NNB=SYMRWM3VLWMEQ; nsr_acl_nautocomplete=1; nvn_ofc; nvnc_cnt=0; refreshx=1

- 야후코리아 비로그인 상태 쿠키값
B=05hdgc149j8fk&b=4&d=xsUQMcRpYFwQBbroDQmsZiftY5LUe9LW7p4-&s=qk; KR_S1=qh=uqO4rsW4vbp8fMDPueMgsOG55nx8wMzDtbz2IMHWuNSwqMDafHy9usbkwM4gwM6wo7Gkv.y6tHx8uMW4s8f8ILPXuvGw1MDMvMcgsLPBtnx8uMW4s8f8ILPXuvGw1MDMvMcgvLPEoXx8s9e68bDUwMy8xyC8s8ShfHzDu7Tjuem53Xx8uK652cDMvbp8fMG2wM68uiC8usCvuK4gyK26uHx8&qc=2; ukfmp=; SO=v%3D0.3%26t%3D1236516693; DetailInfoList=CPN03023604=@|@=CPN03#|#%BF%F8%B5%BF%C0%DA%BF%AC%C8%DE%BE%E7%B8%B2#|#1408015007#|#%B3%BB%C6%F7%B8%AE#|##|#=|=CPN03033712=@|@=CPN03#|#%BE%E7%BB%EA%B3%BB%BF%F8%BB%E7%B0%E8%B0%EE#|#1408008007#|#%BF%EB%BF%AC%B8%AE#|##|#=|=2609679516#|#%B9%E9%BE%CF%BB%EA%B0%FC%B1%A4%B3%F3%BF%F8#|#1510004001#|#%BC%B1%B1%B8%B8%AE#|#1040#|#%C0%AF%BF%F8%C1%F6%2C%B3%EE%C0%CC%B5%BF%BB%EA=|=CPN03539153=@|@=CPN03#|#%BF%EB%B9%AE%BB%EA%C0%DA%BF%AC%C8%DE%BE%E7%B8%B2#|#0807003002#|#%B9%E9%BE%C8%B8%AE#|##|#=|=2604928166#|#%BC%F6%B7%B9%BD%C7%B0%A1%B5%E7#|#0802001007#|#%B4%C9%C6%F2%B8%AE#|#2566#|#%BF%C0%B8%AE%C5%C1; KR_DIC=qh=wM3Az3x8ud217cDMfHy53bXlvcN8fFBoYXNlfHxzdXJwcmlzZXJ8fLW_sbx8fGtvcmVhfHxhdXR1bW58fLChwLt8fGRpbm5lcnx8&qc=2; F=a=VL2ERowMvTDTsxLqZnoYxLShA5afemiwdkJHZOwFydiLYkN7CORv9y8RkALG83rZwvdrmhI-&b=6LFT; YLS=v=1&p=0&n=9; C=mg=1; ykfpBktB=6; Y=v=1&n=fvgqhvvcjpv1c&p=; NP_C=sony080818; FPEK=LG%uD30C%uC6CC%uCF64; mgs_tt=47566510664469146915; mgs_tp=5689678668936901689769097390; mgs_cookie=0502%3A5%2C0302%3A3%2C05%3A2%2C0501%3A2%2C03%3A1%2C031003%3A1%2C0401%3A1%7C3; mgs_tab=lst; mgs_p=1
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 : Comment 0

browser cookie restriction

ITWeb/개발일반 2009.03.11 10:23
ref. http://www.nczonline.net/blog/2008/05/17/browser-cookie-restrictions/
ref. http://blogs.msdn.com/ie/archive/2007/08/29/update-to-internet-explorer-s-cookie-jar.aspx

I’ve been doing some research into cookies for my upcoming book and came across some interesting facts about the way browsers handle cookies. I started out by looking at the number of cookies that browsers allowed per domain. The results were interesting:

  • Microsoft indicated that Internet Explorer 8 increased the cookie limit per domain to 50 cookies but I’ve found that IE7 also allows 50 cookies per domain. Granted, this may have been increased with a system patch rather than having the browser’s first version ship like this, but it’s still more than the 20 that was commonly understood to be the limit.
  • Firefox has a per-domain cookie limit of 50 cookies.
  • Opera has a per-domain cookie limit of 30 cookies.
  • Safari/WebKit is the most interesting of all as it appears to have no perceivable limit through Safari 3.1. I tested setting up to 10,000 cookies and all of them were set and sent along in the Cookie header. The problem is that the header size exceeded the limit that the server could process, so an error occurred.

So the prevailing knowledge that browsers limit per-domain cookies to 20 is no longer valid. Another interesting inconsistency is how browsers react when too many cookies are set. With the exception of Safari, which sets all cookies regardless of the number, there are two approaches:

  1. The least recently used (LRU) approach automatically kicks out the oldest cookie when the cookie limit has been reached in order to allow the newest cookie some space. Internet Explorer and Opera use this approach.
  2. Firefox does something strange: it seems to randomly decide which cookies to keep although the last cookie set is always kept. There doesn’t seem to be any scheme it’s following at all. The takeaway? Don’t go above the cookie limit in Firefox.

The total size of cookies also varies from browser to browser. This is another one that is a little hard to comprehend, but here’s what my tests show:

  • Firefox and Safari allow cookies with up to 4097 characters, that’s 4096 for the name and value and one for the equals sign.
  • Opera allows cookies with up to 4096 characters, which is for the name, value, and equals sign.
  • Internet Explorer allows cookies with up to 4095 characters, which is for the name, value and, equals sign.
크리에이티브 커먼즈 라이선스
Creative Commons License
tags : Cookie, 쿠키
Trackback 0 : Comment 0

티스토리 툴바