首页 新闻 赞助 找找看

Cookies的一個問題

0
悬赏园豆:10 [已关闭问题]
我寫了一個Cookie用來測試客戶端的訪問記錄,但是有一個小問題,統計數據不能變化,請幫忙看看是什麽問題,謝謝!<br> <div class="cnblogs_code">&lt;%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%&gt;<br>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br>&lt;head&gt;<br>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br>&lt;title&gt;上次訪問時間&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;%<br>&nbsp;&nbsp; dim LastVisit<br>&nbsp;&nbsp; dim VisitCount<br>&nbsp;&nbsp; LastVisit=request.Cookies("LastVisitCookie")<br>&nbsp;&nbsp; response.Cookies("LastVisitCookie")=FormatDatetime(now())<br>&nbsp;&nbsp; response.Cookies("LastVisitCookie").expires=date()+30<br>&nbsp;&nbsp; VisitCount=request.Cookies("VisitCount")<br>&nbsp;&nbsp; if VisitCount &gt; "0" then<br>&nbsp;&nbsp;&nbsp;&nbsp; VisitCount=VisitCount+1<br>&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp; VisitCount=1<br>&nbsp;&nbsp; end if<br>&nbsp;&nbsp; response.Cookies("VisisCount")=VisitCount<br>&nbsp;&nbsp; response.Cookies("VisitCount").expires=date()+30&nbsp; <br>%&gt;<br>&lt;body&gt;<br>&lt;p&gt;使用Cookies&lt;/p&gt;<br>&nbsp; &lt;hr /&gt;<br>&nbsp;&nbsp;&nbsp; &lt;%<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; if LastVisit="" then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; response.Write("歡迎光臨本站")<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; response.Write "你上一次訪問本頁在" &amp; LastVisit &amp; "&lt;br&gt;"<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;response.Write "你這是第&lt;font size='8' color='ccbbaa'&gt; " &amp; VisitCount &amp; "&lt;/font&gt;次訪問本頁"<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; end if <br>&nbsp;&nbsp;&nbsp; %&gt;<br>&lt;p&gt;&lt;a href="CookiesDemo.asp"&gt;重新訪問本頁&lt;/a&gt;&lt;/p&gt;&nbsp;&nbsp;&nbsp; <br>&lt;/body&gt;<br>&lt;/html&gt;<br><span id="Code_Closed_Text_142615" class="cnblogs_code_Collapse"></span></div>
zhenhgtuag的主页 zhenhgtuag | 初学一级 | 园豆:165
提问于:2008-08-25 14:28
< >
分享
其他回答(1)
0
if VisitCount > "0" then VisitCount=VisitCount+1 else VisitCount=1 你这是?> "0"字符串?
roboth | 园豆:28 (初学一级) | 2008-08-25 15:13
0
VisitCount=request.Cookies("VisitCount")返回的是一个HttpCookie对象实例,不能和字符串直接比较,取得Cookie的值应该: visiteCookie=request.Cookies("VisitCount") if visiteCookie is Nothing then 'cookie是空时的处理 else cookieValue = visiteCookie.Value; '有值时的处理 end if
玉开 | 园豆:8822 (大侠五级) | 2008-08-26 08:37
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册