The realization method of cookie reading and writing in ASP

Source: Internet
Author: User
Tags generator key visual studio
Cookie|cookie writecookie.asp

<%@ Language=vbscript
%>
<%Response.Buffer=true%>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
<TITLE> Write cookies For 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, 1999"

Response.Cookies ("Cookie2") ("key2") = "KeyValue1"
Response.Cookies ("Cookie2") ("key2") = "KeyValue2"
Response.Cookies ("Cookie2"). Expires = "July 31, 1999"
' Response.Cookies ("Cookie2"). Path = "/testasp/"
' This should be noted in the use of
' is the file specified in that directory to be able to read the contents of this cookie.
' In this example. Only files in the testasp directory can be read
' Cookie2 's content.
%>

</BODY>
</HTML>

-------------------------------------------------------
Readwrite.asp

<%@ Language=vbscript%>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
<TITLE> read Cookies For example </TITLE>
</HEAD>
<BODY>

<%response.write "Read Cookie:<br>"

Dim Cookie,key

For all cookies in Request.Cookies
If Request.Cookies (cookie). HasKeys Then
Response.Write "<br>cookie Name:" &cookie& "<BR>--------------<BR>"
For each key in Request.Cookies (cookie)

Response.Write "Key Name:" &key& ", Value:" &request.cookies (cookie) (Ke
Y) & "<BR>"
Next
Else
Response.Write "Cookie Name:" &request.cookies (Cookie) & "<BR>"
End If

Next

%>
</BODY>
</HTML>



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.