<% @ language = "vbscript"%>
<% option explicit %>
<html>
<head>
<title>读写cookies示例</title>
</head>
<body>
<%
dim username,usersex,n
if request.cookies("user")("name")<>"" and request.cookies("user")("sex")<>"" then
	username=request.cookies("user")("name")
	usersex = request.cookies("user")("sex")
	n=request.cookies("user")("visitedtimes")
	if n="" then
  		n=1
	else
  		n=n+1
	end if
	if usersex = "男" then
		response.write username & "先生，欢迎你访问本页面！"  
	elseif usersex = "女" then
  		response.write username & "小姐，欢迎你访问本页面！"
	end if
	response.write "<p>本页面当前已经被访问<b>" & n & "</b>次了。</p>"	
else
	response.clear()
	server.Execute "4-12b.asp"
	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.Redirect "4-12a.asp"
	end if
end if
	response.cookies("user")("visitedtimes") =n
	response.cookies("user")("name")=username
	response.cookies("user")("sex")=usersex
	response.cookies("user").Expires=#2030-1-1#
%>
</body>
</html>
