??1
//
?utility?function?to?retrieve?an?expiration?date?in?proper
??2
??3
//
?format;?pass?three?integer?parameters?for?the?number?of?days,?hours,
??4
??5
//
?and?minutes?from?now?you?want?the?cookie?to?expire?(or?negative
??6
??7
//
?values?for?a?past?date);?all?three?parameters?are?required,
??8
??9
//
?so?use?zeros?where?appropriate
?10
?11
function
?getExpDate(days,?hours,?minutes)?
{
?12
?13
????
var
?expDate?
=
?
new
?Date(?);
?14
?15
????
if
?(
typeof
?days?
==
?
"
number
"
?
&&
?
typeof
?hours?
==
?
"
number
"
?
&&
?
?16
?17
????????
typeof
?hours?
==
?
"
number
"
)?
{
?18
?19
????????expDate.setDate(expDate.getDate(?)?
+
?parseInt(days));
?20
?21
????????expDate.setHours(expDate.getHours(?)?
+
?parseInt(hours));
?22
?23
????????expDate.setMinutes(expDate.getMinutes(?)?
+
?parseInt(minutes));
?24
?25
????????
return
?expDate.toGMTString(?);
?26
?27
????}
?28
?29
}
?30
?31
???
?32
?33
//
?utility?function?called?by?getCookie(?)
?34
?35
function
?getCookieVal(offset)?
{
?36
?37
????
var
?endstr?
=
?document.cookie.indexOf?(
"
;
"
,?offset);
?38
?39
????
if
?(endstr?
==
?
-
1
)?
{
?40
?41
????????endstr?
=
?document.cookie.length;
?42
?43
????}
?44
?45
????
return
?unescape(document.cookie.substring(offset,?endstr));
?46
?47
}
?48
?49
???
?50
?51
//
?primary?function?to?retrieve?cookie?by?name
?52
?53
function
?getCookie(name)?
{
?54
?55
????
var
?arg?
=
?name?
+
?
"
=
"
;
?56
?57
????
var
?alen?
=
?arg.length;
?58
?59
????
var
?clen?
=
?document.cookie.length;
?60
?61
????
var
?i?
=
?
0
;
?62
?63
????
while
?(i?
<
?clen)?
{
?64
?65
????????
var
?j?
=
?i?
+
?alen;
?66
?67
????????
if
?(document.cookie.substring(i,?j)?
==
?arg)?
{
?68
?69
????????????
return
?getCookieVal(j);
?70
?71
????????}
?72
?73
????????i?
=
?document.cookie.indexOf(
"
?
"
,?i)?
+
?
1
;
?74
?75
????????
if
?(i?
==
?
0
)?
break
;?
?76
?77
????}
?78
?79
????
return
?
""
;
?80
?81
}
?82
?83
???
?84
?85
//
?store?cookie?value?with?optional?details?as?needed
?86
?87
function
?setCookie(name,?value,?expires,?path,?domain,?secure)?
{
?88
?89
????document.cookie?
=
?name?
+
?
"
=
"
?
+
?escape?(value)?
+
?90
?91
????????((expires)?
?
?
"
;?expires=
"
?
+
?expires?:?
""
)?
+
?92
?93
????????((path)?
?
?
"
;?path=
"
?
+
?path?:?
""
)?
+
?94
?95
????????((domain)?
?
?
"
;?domain=
"
?
+
?domain?:?
""
)?
+
?96
?97
????????((secure)?
?
?
"
;?secure
"
?:?
""
);
?98
?99
}
100
101
???
102
103
//
?remove?the?cookie?by?setting?ancient?expiration?date
104
105
function
?deleteCookie(name,path,domain)?
{
106
107
????
if
?(getCookie(name))?
{
108
109
????????document.cookie?
=
?name?
+
?
"
=
"
?
+
110
111
????????????((path)?
?
?
"
;?path=
"
?
+
?path?:?
""
)?
+
112
113
????????????((domain)?
?
?
"
;?domain=
"
?
+
?domain?:?
""
)?
+
114
115
????????????
"
;?expires=Thu,?01-Jan-70?00:00:01?GMT
"
;
116
117
????}
118
119
}
120
121

??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

116

117

118

119

120

121
