Anyone who has been on the internet knows Cookies, which are commonly known as Cookies. Cookies are short texts sent from the server to the client.
This handle allows the website to store some specific information on the user's local hard disk by sending Cookies to the browser.
Read the stored information from the hard disk to complete some operations. For example, some websites that allow visitors to customize pages can use Cookies to "remember" users'
Customization hobbies, and some e-commerce websites also use Cookies.
Many people worry that the application of Cookies will bring security issues. In fact, this worry is not necessary because Cookies cannot be obtained across websites.
Many browsers provide the option to block Cookies.
You may think that Cookies are difficult to implement, but they are not. Please refer to the example below. This example mainly enables the website to "remember" visitors through Cookies.
In this way, when a visitor logs on to the website again, the website displays some personal information for the visitor.
Welcome information, such as "XXX, Hello". Is it very kind?
Code list:
Enrol. asp
<%
Response. cookies ("information") ("name") = request. form ("name ")
Response. cookies ("information") ("age") = request. form ("age ")
Response. cookies ("information") ("nation") = request. form ("nation ")
%>
<Html>
<Head>
<Title> Cookies Demo </title>
</Head>
<Body>
<Form method = "post" action = "enrol. asp">
Name:
<Input type = "text" name = "name">
<P>
Age:
<Input type = "text" name = "age">
<P>
Nation: <input type = "text" name = "nation">
<P>
<Input type = "submit">
<Input type = "reset">
</Form>
</Body>
</Html>
This code is an ASP program, but it is essentially a text file, so you can use "notepad" to edit it. In addition, you need PWS4.0 for local debugging to save the above code
Asp file named enrol. asp. Save path C: Inetpubwwwroot (PWS default installation ).
The program defines a cookie Dictionary named information, which has three subkeys: name, age, and nation, respectively used to record the last name of a visitor.
Name, age, and country. If you need more information, you can define more subkeys.
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