커뮤니티

고용노동부, 산업인력공단과 함께하는 강원도 유일한 기업중심 IT전문교육기관 ICT융합캠퍼스만의 특별한교육입니다.
공인 IT숙련기술인의 다양한 접근방법으로 전문가다운 실무교육을 받을 수 있습니다.

Category

교육강좌

WEB WEB2 - Node.js - Express - Node.js - 쿠키와 인증 - 쿠키 옵션 - path & domain

페이지 정보

작성자 관리자 댓글 0건 조회 2,578회 작성일 20-06-03 16:18

본문

쿠키 옵션 - path & domain

수업소개

쿠키의 유효범위를 정의하는 path와 domain 옵션을 살펴봅시다. 

 

 

 

강의

 

 

 

소스코드

변경사항

nodejs/cookie.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var http = require('http');
var cookie = require('cookie');
http.createServer(function(request, response){
console.log(request.headers.cookie);
var cookies = {};
if(request.headers.cookie !== undefined){
cookies = cookie.parse(request.headers.cookie);
}
console.log(cookies.yummy_cookie);
response.writeHead(200, {
'Set-Cookie':[
'yummy_cookie=choco',
'tasty_cookie=strawberry',
`Permanent=cookies; Max-Age=${60*60*24*30}`,
'Secure=Secure; Secure',
'HttpOnly=HttpOnly; HttpOnly',
'Path=Path; Path=/cookie',
'Doamin=Domain; Domain=test.o2.org'
]
});
response.end('Cookie!!');
}).listen(3000);

 

  • 트위터로 보내기
  • 페이스북으로 보내기
  • 구글플러스로 보내기

답변목록

등록된 답변이 없습니다.