Implementation of Cookie read/write in ASP

Source: Internet
Author: User
Writecookie. asp
<% @ Language = VBScript
%>
<% Response. Buffer = true %>
<HTML>
<HEAD>
<Meta name = "GENERATOR" Content = "Microsoft Visual Studio 6.0">
<TITLE> Cookie writing example </TITLE>
</HEAD>
<BODY>
<%
Response. Write "Write Cookie: <br>"
Response. Cookies ("Cookie1") ("key1") = "KeyValue1"
Response. Cookies ("Cookie1") ("key1") = "KeyValue2"
Response. Cookies ("Cookie1"). Expires = "July 31,199 9"
Response. Cookies ("Cookie2") ("key2") = "KeyValue1"
Response. Cookies ("Cookie2") ("key2") = "KeyValue2"
Response. Cookies ("Cookie2"). Expires = "July 31,199 9"
'Response. Cookies ("Cookie2"). Path = "/testasp /"
'Note this when using
'Is the file specified in that directory to read the cookie content.
'In this example. Only files in the testasp directory can be read.
'Cookie2 content.
%>
</BODY>
</HTML>
-------------------------------------------------------
Readwrite. asp
<% @ Language = VBScript %>
<HTML>
<HEAD>
<Meta name = "GENERATOR" Content = "Microsoft Visual Studio 6.0">
<TITLE> read Cookie example </TITLE>
</HEAD>
<BODY>
<% Response. Write "read Cookie: <br>"
Dim cookie, key
    
For each cookie in Request. Cookies
If Request. Cookies (Cookies). haskeys then
Response. Write "<br> Cookie name:" & cookie & "<BR> ------------ <BR>"
For each key in Request. Cookies (Cookies)
Response. Write "Key name:" & key & ", value:" & Request. Cookies (Cookies) (ke
Y) & "<BR>"
Next
Else
Response. Write "Cookie name:" & Request. Cookies (Cookies) & "<BR>"
End if
     
Next
     
%>
</BODY>
</HTML>

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.