-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
53 lines (50 loc) · 1.31 KB
/
index.html
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
<html lang="ko">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>쿠키 테스트</title>
<style>
table {
width: 100%;
}
th, td {
border: 1px solid black;
text-align: center;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('now').innerText = new Date().toLocaleTimeString();
document.getElementById('foo').innerText = Cookies.get('foo') || '';
});
function setCookie() {
Cookies.set('foo', new Date().toLocaleTimeString(), {expires: 7});
location.reload();
}
function deleteCookie() {
Cookies.remove('foo');
location.reload();
}
</script>
</head>
<body>
<table>
<thead>
<tr><th>Key</th><th>Value</th></tr>
</thead>
<tbody>
<tr>
<td>현재 시각</td>
<td id="now"></td>
</tr>
<tr>
<td>Cookie</td>
<td id="foo"></td>
</tr>
</tbody>
</table>
<button onclick="setCookie()">쿠키 설정</button>
<button onclick="deleteCookie()">쿠키 제거</button>
</body>
</html>