当前位置: 首页 > 图文教程 > 网络编程 > ASP > 使用Cookie来跟踪用户

ASP
迁移到 ASP .NET:需考虑的重要问题(2)
ASP中优化数据库处理
结合XML, ADO, 以及ASP
在ASP中优化数据库处理
提高ASP性能的最佳选择(一)
返回UPDATE SQL语句所影响的行数的方法
ASP如何使用MYSQL数据库
安全维护 IIS asp 站点的高级技巧
也谈ASP中的RESPONSE属性
ASP提速技巧
在ASP中如何访问Novell下的数据库
改善ASP性能和外观的技巧集锦(上)
改善ASP性能和外观的技巧集锦(中)
改善ASP性能和外观的技巧集锦(下)
利用ASP在浏览器上打印输出
用ASP文件实现CPU的使用率始终保持100%
ASP 0115 Error的解决方案
Varchar与char的区别
探讨一下rs(0)和rs(fieldname)的执行效率
连接WEB数据库的ADO性能提高技巧

ASP 中的 使用Cookie来跟踪用户


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 51 ::
收藏到网摘: n/a

  Source Code:



<%

'*** Keeping track of how many times
'*** a user visits a web page, by
'*** reading and writing cookies.

'*** In this example "asphole" will be
'*** the name of our cookie, and
'*** "totalvisit" will be the 'key'
'*** value we keep track of. You can
'*** have multiple 'keys' for each
'*** cookie.

'*** Declare your variables
Dim NumVisit

'*** Check to see how many times they
'*** have been to your web page.
NumVisit = Request.Cookies("asphole")("totalvisit")

'*** If this is their first visit to
'*** the page NumVisit is blank, so
'*** make the value of NumVisit 0.
If NumVisit = "" Then
NumVisit = 0
End If

'*** Display how many times they have
'*** visited your web page.
Response.Write "Visits to this page: " & NumVisit

'*** Count the visit to the web page
NumVisit = NumVisit + 1

'*** Write the new total back to
'*** the cookie in their browser
Response.Cookies("asphole")("totalvisit") = NumVisit

'*** Specify when the cookie expires.
'*** If you don't, the cookie will
'*** expire when the user closes their
'*** browser, and you'll lose all info.
Response.Cookies("asphole").Expires = "January 1, 2020"

%>




-END-