好奇怪的问题!!!

cmexp 2003-01-04 02:52:34
(因为我的问题不见了,所以再重发一次)

谁可以帮忙试一下下面的代码?

我在win xp 的 IIS 5.1上和网上的服务器都试过了,
都一样有问题。

"LastVisitCookie" 的值在下面几行后:

var CurrentDate = new Date();
Response.Cookies("CookieJScript") = CurrentDate.toLocaleString();
Response.Cookies("CookieJScript").Expires = "July 31, 2004";

就自动被改成和 "CurrentDate" 一样的值了

谁能告诉我究竟错在那里?


下面是我的asp:


<%@ LANGUAGE = JScript %>


<%
Response.Expires = 0;

var LastVisitCookie;
LastVisitCookie = Request.Cookies("CookieJScript");

//下面这行 "LastVisitCookie" 的值和两行后的值不一样。(正确)
Response.Write("LastVisitCookie is: " + LastVisitCookie + "<p>");

var CurrentDate = new Date();

Response.Cookies("CookieJScript") = CurrentDate.toLocaleString();

Response.Cookies("CookieJScript").Expires = "July 31, 2004";
//现在 "LastVisitCookie" 的值不知为何被改为和 "CurrentDate "一样了(有问题)
Response.Write("<p>The current date is: " + CurrentDate.toLocaleString() + "</p>");

%>

<HTML>
<HEAD>
<TITLE>Using Cookies</TITLE>
</HEAD>

<BODY BGCOLOR="White" TOPMARGIN="10" LEFTMARGIN="10">

<FONT SIZE="4" FACE="ARIAL, HELVETICA">
<B>Using Cookies</B></FONT><BR>

<HR SIZE="1" COLOR="#000000">

<%
if (LastVisitCookie == "")
{
Response.Write("Welcome to this page.");
}
else
{
//这里"LastVisitCookie" 的值也一样不是Request.Cookies("CookieJScript")后 的值! (有问题)
Response.Write("You last visited this page on " + LastVisitCookie);
}
%>

<P><A HREF="http://test.asp/">Revisit This Page</A>

</BODY>
</HTML>
...全文
29 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
cmexp 2003-01-04
  • 打赏
  • 举报
回复
这两行不就有问题了吗?!!!
两行的值不应该一样啊!!!

//(这是CurrentDate)
The current date is: 2003年1月4日 17:14:27


//(这是LastVisitCookie, 应该是17:14:19 而不是17:14:27 !!!)
You last visited this page on 2003年1月4日 17:14:27
孟子E章 2003-01-04
  • 打赏
  • 举报
回复
iis5+w2k没有问题呀

LastVisitCookie is: 2003年1月4日 17:14:19

The current date is: 2003年1月4日 17:14:27

Using Cookies

--------------------
You last visited this page on 2003年1月4日 17:14:27

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧