The method for saving information to the user's client hard disk in Javascript is relatively limited. This is due to security considerations. However, the hard disk write restrictions greatly reduce the Javascript functionality. In this case, the cookie is generated-a restricted Method for writing data to the hard disk.
Cookie restrictions:
These restrictions include. Browser Cookies cannot exceed 300, and each cookie cannot exceed 4 kb. Therefore, the total cookie file size is limited to bytes kb. Each site has no more than 20 cookies.
Cookie storage location:
The netscape4.x browser places the cookie in "E:/program files/Netscape/users/chendian/cookies.txt" where "E:/Program Files" is the location where your browser is installed, "chendian" is your user name.
In IE, cookies are placed in F:/Windows/profiles/C/cookies/c@www_glisp_com(52.16.txt, where "F:/Windows" is the location where windows is installed, c In "profiles/C" is the user name when you log on to Windows.
Of course, you can delete any cookies you do not want to retain by editing the above files.
Here is an example of reading and writing cookies. You can copy them and use them directly on your webpage.
cookie read/write method:
1. Write. You only need a javascript statement to set the cookie, for example:
document. cookie = "CHD = OK";
in this example, the name of the cookie variable you want to set is "OK.
2. Read.
function getcookieval (offset)
{< br> var endstr = document. cookie. indexof (";", offset);
If (endstr =-1)
endstr = document. cookie. length;
return Unescape (document. cookie. substring (offset, endstr);
}< br> function getcookie (name)
{< br> var Arg = Name + "= ";
var Alen = Arg. length;
var clen = document. cookie. length;
var I = 0;
while (I {< br> var J = I + Alen;
If (document. cookie. substring (I, j) = Arg)
return getcookieval (j);
I = document. cookie. indexof ("", I) + 1;
if (I = 0)
break;
}< br> return NULL;
}< br> alert ("coke CHD =" + getcookie ('cct');
Use getcookie ("Cookie variable name ") you can read the previously set cookie.