javascript 자바스크립트 쿠키( 하루동안 열지 않음)
페이지 정보
본문
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>
<title> New Document </title>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />
<script type=\"text/javascript\">
function setCookie(name, value, expire) {
var expires = new Date();
document.cookie = name + \"=\" + escape(value) + ((expire == null) ? \"\" : (\"; expires=\" + expire.toGMTString()));
}
function setCookie2( name, value, expiredays ) {
var todayDate = new Date();
todayDate.setDate( todayDate.getDate() + expiredays );
document.cookie = name + \"=\" + escape( value ) + \"; path=/; expires=\" + todayDate.toGMTString() + \";\"
}
function setCookie3(c_name,value,exdays){
var exdate=new Date();
//exdate.setDate(exdate.getDate() + exdays); //okj 날짜
//exdate.setDate(exdate.getTime() + 1000*60*60*24*exdays); //okj 시간
exdate.setDate(exdate.getMinutes() + exdays); //okj 분
var c_value=escape(value) + ((exdays==null) ? \"\" : \"; expires=\"+exdate.toUTCString());
document.cookie=c_name + \"=\" + c_value;
}
function getCookie(Name) {
var search = Name + \"=\";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if (offset != -1){
offset += search.length;
end = document.cookie.indexOf(\";\", offset);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(offset, end));
}
}
}
//alert(getCookie('test'));
//window.onload = function() { setCookie2('test','',-1); alert(getCookie('test')); };
</script>
</head>
<body>
쿠키가 안먹는다 왜?
<input type=\"button\" value=\"생성\" onclick=\"setCookie2('test1','1234',1)\">
<input type=\"button\" value=\"보기\" onclick=\"alert(getCookie('test'))\">
<input type=\"button\" value=\"삭제\" onclick=\"setCookie2('test1','',-1)\">
</body>
</html>
<html>
<head>
<title> New Document </title>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />
<script type=\"text/javascript\">
function setCookie(name, value, expire) {
var expires = new Date();
document.cookie = name + \"=\" + escape(value) + ((expire == null) ? \"\" : (\"; expires=\" + expire.toGMTString()));
}
function setCookie2( name, value, expiredays ) {
var todayDate = new Date();
todayDate.setDate( todayDate.getDate() + expiredays );
document.cookie = name + \"=\" + escape( value ) + \"; path=/; expires=\" + todayDate.toGMTString() + \";\"
}
function setCookie3(c_name,value,exdays){
var exdate=new Date();
//exdate.setDate(exdate.getDate() + exdays); //okj 날짜
//exdate.setDate(exdate.getTime() + 1000*60*60*24*exdays); //okj 시간
exdate.setDate(exdate.getMinutes() + exdays); //okj 분
var c_value=escape(value) + ((exdays==null) ? \"\" : \"; expires=\"+exdate.toUTCString());
document.cookie=c_name + \"=\" + c_value;
}
function getCookie(Name) {
var search = Name + \"=\";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if (offset != -1){
offset += search.length;
end = document.cookie.indexOf(\";\", offset);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(offset, end));
}
}
}
//alert(getCookie('test'));
//window.onload = function() { setCookie2('test','',-1); alert(getCookie('test')); };
</script>
</head>
<body>
쿠키가 안먹는다 왜?
<input type=\"button\" value=\"생성\" onclick=\"setCookie2('test1','1234',1)\">
<input type=\"button\" value=\"보기\" onclick=\"alert(getCookie('test'))\">
<input type=\"button\" value=\"삭제\" onclick=\"setCookie2('test1','',-1)\">
</body>
</html>
관련링크
-
https://blog.naver.com/ish430/40209559162
4622회 연결 -
https://rocabilly.tistory.com/98
5941회 연결
- 이전글javascript 자바스크립트 공통함수 comm_js 20.02.21
- 다음글php 날짜 제어 new 20.02.21
댓글목록
등록된 댓글이 없습니다.