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
/* Modifed by BL to namespace the functions */
/*
DISCLAIMER: THESE JAVASCRIPT FUNCTIONS ARE SUPPLIED 'AS IS', WITH
NO WARRANTY EXPRESSED OR IMPLIED. YOU USE THEM AT YOUR OWN RISK.
NEITHER PAUL STEPHENS NOR PC PLUS MAGAZINE ACCEPTS ANY LIABILITY FOR
ANY LOSS OR DAMAGE RESULTING FROM THEIR USE, HOWEVER CAUSED.
Paul Stephens' NetScape-based cookie-handling library
http://web.ukonline.co.uk/paul.stephens/index.htm
TO USE THIS LIBRARY, INSERT ITS CONTENTS IN A <script></script> BLOCK IN THE
<HEAD> SECTION OF YOUR WEB PAGE SOURCE, BEFORE ANY OTHER JAVASCRIPT ROUTINES.
Feel free to use this code, but please leave this comment block in.
*/
var Cookies = {
setCookie: function(name, value, lifespan, access_path) {
var cookietext = name + "=" + escape(value)
if (lifespan != null) {
var today=new Date()
var expiredate = new Date()
expiredate.setTime(today.getTime() + 1000*60*60*24*lifespan)
cookietext += "; expires=" + expiredate.toGMTString()
}
if (access_path != null) {
cookietext += "; PATH="+access_path
}
document.cookie = cookietext
return null
},
setDatedCookie: function(name, value, expire, access_path) {
var cookietext = name + "=" + escape(value)
+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
if (access_path != null) {
cookietext += "; PATH="+access_path
}
document.cookie = cookietext
return null
},
getCookie: function(Name) {
var search = Name + "="
var CookieString = document.cookie
var result = null
if (CookieString.length > 0) {
offset = CookieString.indexOf(search)
if (offset != -1) {
offset += search.length
end = CookieString.indexOf(";", offset)
if (end == -1)
end = CookieString.length
result = unescape(CookieString.substring(offset, end))
}
}
return result
},
deleteCookie: function (Name, Path) {
Cookies.setCookie(Name,"Deleted", -1, Path)
}
}