<% @ language = "vbscript"%>
<% option explicit %>
<html>
<head>
<title>读写cookies示例</title>
</head>
<body>
<%
dim username,usersex,n
if request.form("username")<>"" and request.form("usersex")<>"" then

	username=request.form("username")
	usersex=request.form("usersex")
	response.cookies("user")("name")=username
	response.cookies("user")("sex")=usersex
	response.cookies("user")("visitedtimes")=n
elseif request.cookies("user")("name")<>"" and request.cookies("user")("sex")<>"" then
	response.clear()
	else
	response.Redirect "5-23.htm"
	response.End()
end if
	n=request.cookies("user")("visitedtimes")
if n="" then
  n=1
else
  n=n+1
end if
	username=request.cookies("user")("name")
	usersex = request.cookies("user")("sex")
if usersex = "男" then
	response.write username & "先生，欢迎你访问本页面！"  
elseif usersex = "女" then
  response.write username & "小姐，欢迎你访问本页面！"
end if
	response.write "<p>本页面当前已经被访问<b>" & n & "</b>次了。</p>"
	response.cookies("user")("visitedtimes") =n
	response.cookies("user")("name")=username
	response.cookies("user")("sex")=usersex
	response.cookies("user").Expires=#2030-1-1#
%>
</body>
</html>
