What are cookies? Cookie is actually a tag, which is often heard in Chinese: Little Licking Cookie. When you visit a WEB site that needs to uniquely identify your site, it will leave a tag on your hard drive, and the next time you visit the same site, the site's page will look for this tag.
Each WEB site has its own tag, and the tagged content can be read at any time, but it can only be done by the pages of that site. Cookies for each site exist in different files in the same folder as cookies for all other sites (you can find them in the Cookies folder in the Windows directory of win98, while win2k is in the Cookies folder for specific users under the Documents and Settings folder).
A cookie is a tag that uniquely identifies a customer. A cookie can contain information shared by all pages of a WEB site between a conversation period or several conversation periods. Using cookies can also exchange information between pages. This feature is often used in ASP programs such as requiring authenticated customer passwords and electronic bulletin boards, WEB chat rooms, etc.
Although cookies sound nothing exciting now, in fact, you can achieve many meaningful features with it! For example: you can place a question and answer sheet on the site, ask the visitor for favorite colors and fonts, and then customize the user's web interface based on these. In addition, you can also save the visitor's login password, so that when the visitor visits the site again, you no longer need to enter the password to log in.
Of course, cookies also have some shortcomings. First of all, since the function of cookies can be used to program and implement some bad attempts, most browsers have security settings, which can set whether to allow or accept cookies ("Tools"-"Internet options..."-"Security"-"Customization level"-"Cookie usage"; in Netscape browser, "Tools"-"Cookie Manager"-"Manage stored cookies"), so this cannot guarantee that cookies can be used at any time. Furthermore, visitors may intentionally or unintentionally delete cookies. When the visitor's machine encounters a "blue screen" crash, or after reformatting the hard disk or installing the system, all the original saved cookies will be lost. Last but not least, some initial browsers do not support cookies.
◆ How to use cooklie?
There are 2 basic ways to use cookies:
1. Write cookies to the visitor's computer (using the Response command)
2. Retrieve the cookie from the visitor's computer (using the Request command)
◆ Basic syntax for creating cookies: Response.Cookies(cookie)[(key)|.attribute]=value
The cookie here is the name of the specified cookie.
And if a key is specified, the cookie is a dictionary.
(Test whether a cookie is a dictionary or not, which can be used to display the boolean value in the following code: <%=Request.Cookies("cookiename").HasKeys%>. If true is a dictionary, false is not.)
Attribute Specifies the information about the cookie itself. The Attribute parameter can be one of the following:
①If Domain is specified, the cookie will be sent to the request for the domain. The domain attribute indicates which website the cookie is generated or read. By default, the domain attribute of the cookie is set to the website that generates it, but you can also change it as needed. (Response.Cookies("CookieName").Domain = "www.mydomain.com")