WEB开发网
开发学院WEB开发ASP ASP入门基础教程-Response对象的Cookies集合 阅读

ASP入门基础教程-Response对象的Cookies集合

 2006-10-26 12:00:09 来源:WEB开发网   
核心提示: <% @ language="VBScript" %><% Response.Buffer=true %><html><head><title>读写Cookies示例</title></hea
<% @ language="VBScript" %>
<% Response.Buffer=true %>
<html>
<head>
<title>读写Cookies示例</title>
</head>
<body>
<center>
<%
dim UserName,password,a,b
UserName=Request.Querystring("UserName1") '将名为"UserName1"控件的值赋给变量UserName。
password=Request.Querystring("password1") '将名为"password1"控件的值赋给变量password。
a=Request.Cookies("User")("UserName") '读取Cookies中UserName的值,并将其赋给变量a。
b=Request.Cookies("User")("password") '读取Cookies中password的值,并将其赋给变量b。
%>
<font size='7' color='red' face='华文彩云'>
<%
if UserName=a and password=b then '如果在UserName控件中输入的值等于Cookies中UswrName的值,而且在password控件中输入的值等于Cookies中password的值,则提示”您已登录成功1“
response.write "您已登录成功!"
else
response.Redirect "4-2a1.asp" '否则,返回到用户信息输入页面。
end if
%>
</font>
<hr size="2" width="70%" color="#cc9999">
<%
Response.Cookies("User").Expires=date()+100 '设置Cookies的有效期是100天。
%>
<a href="4-2a1.asp">返回上一页</a>***||***<a href="4-2-2.asp">返回教材</a>
</center>
</body>
</html>

注:执行上述 ASP 程序后,可以在客户端磁盘上找到写入的 Cookie 文件。Cookie 文件的存储位置与所使用的操作系统有关:如果使用的是 Windows 98Me,可以在 WindowsCookies 文件夹中找到该文件;如果使用的是 W in200/XP系统,Cookies文件存放在C:Documents asn Settings 中该用户目录上的 Cookies 子目录中。

查看全套"ASP入门基础"教程>>>>>

上一页  1 2 3 

Tags:ASP 入门 基础

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接