<script language=javascript>
function Setcookies (name,value)
{
var days = 30; This cookie will be saved for 30 days
var exp= new Date (); New Date ("December 31, 9998");
Exp.settime (Exp.gettime () + days*24*60*60*1000);
Document.cookie = name + "=" + Escape (value) + "expire*=" + **p.togmtstring ();
}
function GetCookies (name)
{
var arr = Document.cookie.match (New RegExp ("(^|)" +name+ "= ([^;] *)(;|$)"));
if (arr!= null) return unescape (arr[2)); return null;
}
function GetCookies ()
{
Document.form1.username.value=getcookies ("Loginusername");
\ Put the form you want to initialize here
}
function Delcookies (name)
{
var exp = new Date ();
Exp.settime (Exp.gettime ()-1);
var cval=getcookie (name);
if (cval!=null) document.cookie=name + "=" +cval+ "; expire*=" +**p.togmtstring ();
}
function Submit ()
{
Username=document.form1.username.value;
Setcookies (' Loginusername ', username)
\ Create a cookie, the first name, followed by the value
}
</script>
<body onload= "getcookies ()" >
</body>
/////////////////////////////////////////////////////////////////////
function getexpdate (days, hours, minutes) {
var expdate = new Date ();
if (typeof days = = "Number" && typeof hours = = "Number" &&
typeof hours = = "Number") {
Expdate.setdate (expdate.getdate () + parseint (days));
Expdate.sethours (expdate.gethours () + parseint (hours));
Expdate.setminutes (expdate.getminutes () + parseint (minutes));
return expdate.togmtstring ();
}
}
Utility function called by GetCookie ()
function Getcookieval (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr = = 1) {
Endstr = Document.cookie.length;
}
Return unescape (document.cookie.substring (offset, endstr));
}
primary function to retrieve cookies by name
function GetCookie (name) {
var arg = name + "=";
var alen = Arg.length;
var clen = document.cookie.length;
var i = 0;
while (I < Clen) {
var j = i + Alen;
if (Document.cookie.substring (i, j) = Arg) {
Return Getcookieval (j);
}
i = Document.cookie.indexOf ("", I) + 1;
if (i = = 0) break;
}
Return "";
}
Store cookie value with optional details as needed
function Setcookie (name, value, expires, path, domain, secure) {
Document.cookie = name + "=" + Escape (value) +
((expires)? "; Expires= "+ Expires:" "") +
((path)? "; Path= "+ Path:" "") +
(domain)? "; domain= "+ Domain:" "") +
(secure)? "; Secure ":" ");
}
Remove the cookie by setting ancient expiration date
function Deletecookie (name,path,domain) {
if (GetCookie (name)) {
Document.cookie = name + "=" +
((path)? "; Path= "+ Path:" "") +
(domain)? "; domain= "+ Domain:" "") +
"; Expires=thu, 01-jan-70 00:00:01 GMT ";
}
}