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

ASP
asp+的页面指示标识
asp+文件上传增强实例
让ASP也可以连接MYSQL
ASP文件操作--列出目录及文件
将站点加入频道栏源代码
如何在页面上动态的生成 WebForm控件
避免表单的重复提交又一方法(js)
灵活实用的页面广告实例
如何用javascript识别Netscape 6 浏览器
使用javascript实现邮箱快速登录的方法!!
如何从数据库得到一个列表表单
使用Cookie来跟踪用户
用DHTML来模拟实现下拉菜单
javascript做的数据校验(校验IP地址等)
通过网络域名得到这台主机的IP地址
如何在ASP中使用类
SQL Server中单引号的两种处理技巧
Display data From database into 2 Column
存储过程对页面访问速度的影响
在ASP中使用类

ASP 中的 使用Cookie来跟踪用户


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