1 /*******************************************************
3 Based on "Night of the Living Cookie" by Bill Dortch
6 Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/
7 *******************************************************/
8 function cookie(name
, value
, expires
, path
, domain
, secure
)
21 // To allow for faster parsing
22 var ck
=document
.cookie
;
24 var arg
= this.name
+ "=";
25 var alen
= arg
.length
;
32 if (ck
.substring(i
, j
) == arg
)
34 var endstr
= ck
.indexOf (";", j
);
35 if (endstr
== -1) endstr
= ck
.length
;
36 return unescape(ck
.substring(j
, endstr
));
38 i
= ck
.indexOf(" ", i
) + 1;
47 // Store initial value of "this.expires" for re-initialization.
48 expStore
=this.expires
;
50 // Set time to absolute zero.
53 skew
= base
.getTime();
54 if (skew
> 0) exp
.setTime (exp
.getTime() - skew
);
55 exp
.setTime(exp
.getTime() + (this.expires
*24*60*60*1000));
58 document
.cookie
= this.name
+ "=" + escape (this.value
) +
59 ((this.expires
) ? "; expires=" + this.expires
.toGMTString() : "") +
60 ((this.path
) ? "; path=" + this.path
: "") +
61 ((this.domain
) ? "; domain=" + this.domain
: "") +
62 ((this.secure
) ? "; secure" : "");
65 this.expires
=expStore
;
71 document
.cookie
= this.name
+ "=" +
72 ((this.path
) ? "; path=" + this.path
: "") +
73 ((this.domain
) ? "; domain=" + this.domain
: "") +
74 "; expires=Thu, 01-Jan-70 00:00:01 GMT";
77 // Change cookie settings.
78 this.changeName=function(chName
) { this.kill(); this.name
=chName
; this.set(); }
79 this.changeVal=function(chVal
) { this.kill(); this.value
=chVal
; this.set(); }
80 this.changeExp=function(chExp
) { this.kill(); this.expires
=chExp
; this.set(); }
81 this.changePath=function(chPath
) { this.kill(); this.path
=chPath
; this.set(); }
82 this.changeDomain=function(chDom
) { this.kill(); this.domain
=chDom
; this.set(); }
83 this.changeSecurity=function(chSec
) { this.kill(); this.secure
=chSec
; this.set(); }