网络编程
位置:首页>> 网络编程>> Asp编程>> ASP:Cookie使用指南(4)

ASP:Cookie使用指南(4)

作者:甘冀平翻译  发布时间:2007-09-28 12:48:00 

标签:cookies,指南

例子2 这里有另外一个简单的例子:当访问者第1次浏览某个站点时,向他们显示欢迎信息。代码如下:


< %@ LANGUAGE="VBSCRIPT" % > 
< % 
RequestName = Request.Form("Name") 
RequestLeaveMeAlone = Request.Form("LeaveMeAlone") 
If  RequestName < >"" or RequestLeaveMeAlone < >""  then 
Response.Cookies("MySiteVisitorName") = RequestName 
Response.Cookies("MySiteVisitorName").Expires = #January 01, 2010# 
Response.Cookies("MySiteLeaveMeAlone") = RequestLeaveMeAlone 
Response.Cookies("MySiteLeaveMeAlone").Expires = #January 01, 2010# 
End if 
VisitorName = request.cookies("MySiteVisitorName") 
LeaveMeAlone = request.cookies("MySiteLeaveMeAlone") 
If VisitorName ="" and LeaveMeAlone ="" then 
% > 
< HTML > < HEAD > < /HEAD > 
< body bgcolor="#ccffff" text="black" link="navy" vlink="purple" > 
< DIV ALIGN="CENTER" > 
< form action="index.asp" method="POST" > 
< H2 >Let’s be friends< /H2 > 
What’s your name (leave blank and hit the Submit button if you don’t want us to know)? 
< input type="text" name="name" >< BR >< BR > 
< input type="hidden" name="LeaveMeAlone" value="x" > 
< input type="submit" value="Submit" > 
< /FORM > 
< /DIV > 
< /BODY > 
< % 
End if 
If VisitorName < > "" then 
Response.write "Hi, " & VisitorName & "! I hope you are having a great day!" 
End if 
’rest of the page 
% >


 

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com