웹프로그램
자바스크립트 쿠키를 서브 도메인 공유하기
세이박스
2008. 11. 7. 16:12
반응형
function SetCookie(sName, sValue)
{
var expDays = 7; // 쿠키 만료기간(일수)
var todayDate = new Date();
var cookiePath = "/";
var domain = "gooddaysports.co.kr";
todayDate.setDate(todayDate.getDate() + expDays);
{
var expDays = 7; // 쿠키 만료기간(일수)
var todayDate = new Date();
var cookiePath = "/";
var domain = "gooddaysports.co.kr";
todayDate.setDate(todayDate.getDate() + expDays);
if (sValue == "1") {
document.cookie = sName + "=" + escape(sValue);
} else if (sValue == "2") {
document.cookie = sName + "=" + escape(sValue) + ";" +
"expires=" + todayDate.toGMTString() + ";" +
"path=" + cookiePath + ";" +
"domain=" + domain + ";"
}
}
var pID = "goodday";
document.cookie = sName + "=" + escape(sValue);
} else if (sValue == "2") {
document.cookie = sName + "=" + escape(sValue) + ";" +
"expires=" + todayDate.toGMTString() + ";" +
"path=" + cookiePath + ";" +
"domain=" + domain + ";"
}
}
var pID = "goodday";
ㅜㅜ 도메인관련 찾느라 고생했음.....
http://www.gooddaysports.co.kr 에서 goodday라고 굽은 쿠키가
http://w1.gooddaysports.co.kr 에서 사용 할려면
위 var domain = "gooddaysports.co.kr" 라고 지정해줘야함.
앞에 어떤 서브 도메인이 되었던 gooddaysports.co.kr 도메인에서 동일하게 쿠키를 공유함.
위 글은 세이박스에서 직접 작성한 것으로 퍼가실 경우 반드시 출처와 함께 남기시길 바랍니다.
출처 : 세이박스 http://saybox.tistory.com/
위 글은 세이박스에서 직접 작성한 것으로 퍼가실 경우 반드시 출처와 함께 남기시길 바랍니다.
출처 : 세이박스 http://saybox.tistory.com/
반응형