-
Notifications
You must be signed in to change notification settings - Fork 0
/
cookie.html
38 lines (32 loc) · 873 Bytes
/
cookie.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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Cookie.js test</title>
<script src="cookie.js"></script>
</head>
<body>
<script>
cookie.set('name', 'nino', +new Date() + 3000, '/');
cookie.set('age', 18, {expires: +new Date() + 7000});
cookie.config({expires: +new Date() + 20000});
cookie.config('path', '/');
cookie.set({'key': 'interest', 'value': 'flight'});
function read(usec) {
setTimeout(function() {
console.log('--read after ' + usec + 'ms--');
console.log('name:', cookie.get('name'));
console.log('age:', cookie.get('age'));
console.log('interest:', cookie.get('interest'));
}, usec);
}
read(0);
read(5000);
read(10000);
read(15000);
setTimeout(function() {
cookie.remove('interest');
}, 11000);
</script>
</body>
</html>