Introductory step of ASP Programming (VI): Cookies lectures

Source: Internet
Author: User
What is a Cookie? Cookies are actually a label that can often be heard in Chinese translation: small lick cakes. When you visit a Web site that needs to uniquely identify your site, it leaves a mark on your hard drive, and the next time you visit the same site, the site's page looks for the tag.
Each WEB site has its own tag, and the tagged content can be read at any time, but only by the page of that site. Cookies for each site exist within different files in the same folder as the cookie for all other sites (you can find them in the cookie folder in the Win98 Windows directory, and Win2K in the documents and Settings folder for specific In the user's Cookies folder).
A cookie is a token that uniquely identifies a customer, and a cookie can contain information that is shared by all pages of a WEB site during a conversation or several conversations, and can also be exchanged between pages using cookies. This feature is often used in ASP programs that require authentication of customer passwords as well as electronic bulletin boards, WEB chat rooms, and so on.
Although it sounds a little exciting now, you can actually use it to achieve a lot of meaningful functionality! For example, you can place a survey question and answer table on your site, ask your visitors favorite colors and fonts, and then follow these custom user Web interfaces. Also, you can save the visitor's login password so that when visitors visit the site again, they do not have to enter the password to log in again.
Of course, cookies also have some deficiencies. First, because the use of cookies can be programmed to implement some bad intentions, most browsers have security settings, which can be set whether to allow or accept cookies (ie Browser "tools"-"Internet Options ..."-"Security"-"Custom Level"- -"Use of cookies", Netscape Browser "Tools"-"Cookie Manager"-"Manage stored cookies", so there is no guarantee that cookies can be used at any time. Furthermore, a visitor may intentionally or unintentionally delete a cookie. The original saved cookie will be lost when the visitor's machine encounters a "blue screen" panic, or reformatting the hard drive and installing the system. Finally, some of the most original browsers do not support cookies.
How to use Cooklie?
There are 2 basic ways of using cookies:
1. Write cookies to the visitor's computer (using the Response command)
2. Retrieve cookies from the visitor's computer (using the Request command)
Basic syntax for creating cookies: response.cookies (cookies) [(key) |. Attribute]=value
The cookie here is the name of the specified cookie.
If a key is specified, the cookie is a dictionary.
(Test whether a cookie is a dictionary can be used in the following code to display a Boolean value: <%=request.cookies ("CookieName"). Haskeys%>. True is a dictionary, false is not.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.