메뉴 건너뛰기

조회 수 10924 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

Set-Cookie 헤더의 구성

 

쿠키이름=쿠키값; Domain=도메인값; Path=경로값; Expires=GMT형식의만료일시

 

 

 [코드]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>자바스크립트 아이디저장(쿠키저장)</title>
 
<script>
    window.onload = function() {
 
        if (getCookie("id")) { // getCookie함수로 id라는 이름의 쿠키를 불러와서 있을경우
            document.loginForm.userid.value = getCookie("id"); //input 이름이 id인곳에 getCookie("id")값을 넣어줌
            document.loginForm.idsave.checked = true; // 체크는 체크됨으로
        }
 
    }
 
    function setCookie(name, value, expiredays) //쿠키 저장함수
    {
        var todayDate = new Date();
        todayDate.setDate(todayDate.getDate() + expiredays);
        document.cookie = name + "=" + escape(value) + "; path=/; expires="
                + todayDate.toGMTString() + ";"
    }
 
    function getCookie(Name) { // 쿠키 불러오는 함수
        var search = Name + "=";
        if (document.cookie.length > 0) { // if there are any cookies
            offset = document.cookie.indexOf(search);
            if (offset != -1) { // if cookie exists
                offset += search.length// set index of beginning of value
                end = document.cookie.indexOf(";", offset); // set index of end of cookie value
                if (end == -1)
                    end = document.cookie.length;
                return unescape(document.cookie.substring(offset, end));
            }
        }
    }
 
    function sendit() {
        var frm = document.loginForm;
        if (!frm.userid.value) { //아이디를 입력하지 않으면.
            alert("아이디를 입력 해주세요!");
            frm.userid.focus();
            return;
        }
        if (!frm.pwd.value) { //패스워드를 입력하지 않으면.
            alert("패스워드를 입력 해주세요!");
            frm.pwd.focus();
            return;
        }
 
        if (document.loginForm.idsave.checked == true) { // 아이디 저장을 체크 하였을때
            setCookie("id"document.loginForm.userid.value, 7); //쿠키이름을 id로 아이디입력필드값을 7일동안 저장
        } else { // 아이디 저장을 체크 하지 않았을때
            setCookie("id"document.loginForm.userid.value, 0); //날짜를 0으로 저장하여 쿠키삭제
        }
 
        document.loginForm.submit(); //유효성 검사가 통과되면 서버로 전송.
 
    }
</script>
 
 
</head>
<body>
 
 
    <!-- login.html -->
 
    <form id="loginForm" name="loginForm" method="post"
        action="loginProcess.jsp">
        <table width="100%" height="400" border="0" align="center">
 
            <tr>
                <td>
                    <table border="0" width="300" height="200" align="center"
                        class="loginBorder">
                        <tr align="center">
                            <td>로그인</td>
 
                        </tr>
 
                        <tr>
                            <td>
                                <table border="0" width="100%" height="100%">
                                    <tr>
                                        <td width="30%">아이디</td>
                                        <td width="70%"><input type="text" name="userid"
                                            size="20" maxlength="20"></td>
                                    </tr>
                                    <tr>
                                        <td>패스워드</td>
                                        <td><input type="password" name="pwd" size="20"
                                            maxlength="20"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align="left"><input type="checkbox"
                                            name="idsave" value="saveOk">아이디 저장</td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr align="center">
                            <td><input type="button" value="로그인" onclick="sendit()">
                                <a href="member.html">회원가입 </a></td>
 
                        </tr>
 
                    </table>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

 


 

  


  1. 유효한 링크인지 확인하는 JAVASCRIPT

    Date2019.01.16 Views112152
    Read More
  2. [jQuery] 상위부터 차례로 지역 선택하기

    Date2014.03.01 Views46046
    Read More
  3. Javascript - 이미지 미리보기 회전되어 나옴(EXIF)

    Date2021.03.09 Views36382
    Read More
  4. javascript 인쇄 미리보기, 출력, 페이지 설정 등

    Date2014.03.01 Views32693
    Read More
  5. Checkbox : 체크박스 체크여부 확인

    Date2015.06.19 Views19010
    Read More
  6. 날짜 및 시간 입력 구현하기, Bootstrap DateTimePicker

    Date2017.04.06 Views16541
    Read More
  7. 공백 검사 함수

    Date2015.06.19 Views14627
    Read More
  8. 선택(CheckBox) 된 Row 삭제 - 화면에서 추가된 Row

    Date2015.04.28 Views13541
    Read More
  9. 'focus', 엔터 누르고 이동하자!

    Date2015.02.03 Views12857
    Read More
  10. 라디오버튼 선택 체크여부 radio checked

    Date2014.03.01 Views12671
    Read More
  11. 셀렉트(select) change Ajax 이벤트

    Date2016.12.23 Views12591
    Read More
  12. input type file multiple list (파일 업로드 리스트 확인)

    Date2016.11.17 Views12439
    Read More
  13. 간단한 동적 SELECT 박스 구현하기

    Date2016.10.06 Views12368
    Read More
  14. GET방식으로 전송시 특수문자함께 전송하는 방법

    Date2016.12.22 Views12346
    Read More
  15. 텍스트박스(input type = "text") 숫자 증가, 감소 시키기 - 쇼핑몰 주문 수량

    Date2015.06.19 Views12288
    Read More
  16. 창 크기 최대화 시키기

    Date2015.06.19 Views12228
    Read More
  17. [jQuery] 실시간 검색어 순위 순서대로 보여주기

    Date2014.03.01 Views12019
    Read More
  18. jquery 메뉴 - 아래로 한번에 전체가 펼처짐

    Date2015.04.06 Views11698
    Read More
  19. 'Array', 배열 및 다차원 배열 선언에 대해 알아보자!

    Date2015.02.03 Views11110
    Read More
  20. 랜덤 배너 노출 스크립트

    Date2019.04.29 Views11053
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved