writecookie.asp
<%@ language=vbscript
%>
<%response.buffer=true%>
<html>
<head>
<meta name=”generator” content=”microsoft visual studio 6.0″>
<title>写cookie的示例</title>
</head>
<body>
<%
response.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/”
这个在使用的时候要注意
是指定在那个目录的文件才可以读取这个cookie的内容。
在本例子中。只有在testasp这目录下的文件才可以读取
cookie2的内容。
%>
</body>
</html>
——————————————————-
readwrite.asp
<%@ language=vbscript %>
<html>
<head>
<meta name=”generator” content=”microsoft visual studio 6.0″>
<title>读cookie的示例</title>
</head>
<body>
<%response.write “读取cookie:<br>”
dim cookie,key
for each cookie in request.cookies
if request.cookies(cookie).haskeys then
response.write “<br>cookie 名字:”&cookie&”<br>————–<br>”
for each key in request.cookies(cookie)
response.write “key 名字:”&key&”,值:”&request.cookies(cookie)(ke
y)&”<br>”
next
else
response.write “cookie 名字:”&request.cookies(cookie)&”<br>”
end if
next
%>
</body>
</html>