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

ASP
如何善用Response.Buffer增进浏览速度?
利用 Meta Tag 来增加文件属性
要如何使用 ASP Error 组件?
Server.Execute和#include相异之处
ASP中文本文件与数据库文件的数据交换
如何用ASP建立图表
如何在ASP中通过ODBC调用Excel中的数据
不刷新页面改变下拉菜单内容
使用ASP重启服务器
用模板建立动态ASP页
如何用ASP将一大段文字中的HTML的标识去掉
让使用者可以看到你的ASP的原代码
用ASP实现在特定的时段或对特定访问者开放
在ASP中判断SQL语句是否执行成功
直接显示Monday等星期的ASP语句
LINE 的计数器源程序(附源代码)
使用asp+中的若干问题及解决方案
ASP实现多语言支持
Session对象在各浏览器中的有效范围
SQL Server如何解决加密问题?

ASP 中的 使用Cookie来跟踪用户


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 36 ::
收藏到网摘: 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-