ASP entry-level cookie Application

Source: Internet
Author: User

Cookies are often used to identify users. Cookie is a small file that the server stays on the user's computer. Each time a computer requests a page through a browser, the computer sends a cookie.

 

Cookies are not stored on the server, but stored in the user's browser. This also brings security considerations. For some general security applications, you can use them with little encryption.

 

 

The "response. Cookies" command is used to create a cookie, create a cookie named "firstname", and assign it "Alex ":

 
<% Response. Cookies ("firstname") = "Alex" %>

It is also possible to allocate attributes to cookies, such as setting the cookie expiration time:

 
<% Response. Cookies ("firstname") = "Alex" response. Cookies ("firstname"). expires = # May 10, 2002 # %>
 
The "request. Cookies" command is used to retrieve the cookie value:
 
<% Fname = request. Cookies ("firstname") response. Write ("firstname =" & fname) %>

Output:

 
Firstname = Alex
 
If a cookie contains a set of multiple values, we can say that the cookie has a key (KEYS ).

In the following example, we will create a cookie set named "user. "User" cookies have keys that contain user information:

 
<% Response. cookies ("user") ("firstname") = "John" response. cookies ("user") ("lastname") = "Adams" response. cookies ("user") ("country") = "UK" response. cookies ("user") ("Age") = "25 "%>
 
We will also encounter browsers that do not support cookies. In this way, we can only use other methods to implement cookie functions, such as URL-based value passing or form-based value passing, although this is clumsy.

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.