使用Cookie来跟踪用户

2016-01-29 18:12 2 1 收藏

使用Cookie来跟踪用户,使用Cookie来跟踪用户

【 tulaoshi.com - ASP 】

  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-


 

来源:http://www.tulaoshi.com/n/20160129/1504802.html

延伸阅读
标签: SQLServer
下面是我用SQL的事件探察器设置跟踪,并生成的SQL脚本  现在有几个问题:   1.这个跟踪不会产生数据,用:   select * from ::fn_trace_getinfo(1)  可以看到状态是在运行,但 c:\test.trc 始终是空文件    2.在事件探察器中设置筛选时,ObjectType 的说明是对应sysobjects&nb...
今天想把一个用使用了HttpClient的自动签到小程序移植到Android上,还好Android的SDK自带了HttpClient的包。翻Android的文档时发现官方还提供了一个实现了HttpClient接口的AndroidHttpClient,上网搜了下没发现关于AndroidHttpClient的文章。当然也可以继续使用DefaultHttpClient,但用为Android定制的AndroidHttpClient自然更好。 下面是2个...
标签: Java JAVA基础
      本文介绍了Java Servlet编程所需的软件及环境配置。只要你有一台安装Windows 95/98了的PC机,便可以按照本文的步骤开发Servlet程序了。本文同时给出了通过Java Servlet向用户的硬盘写入和读取Cookie的方法及例程。通过它可以实现网上常见的个性化网页、网上购物篮、密码验证等。 Java Servlet是运行于W...
标签: ASP
  <%@ Page Language="VB" % <script language="VB" runat="server" Const COOKIE_NAME  As String = "test-cookie-name" Const COOKIE_VALUE As String = "test-cookie-value" ' Declare our cookie object Dim objCookieObject As HttpCookie ...
标签: ASP
  我自己曾想写一篇关于Cookie的文章,特别是Client端Script同Server端ASP通过Cookie交互的问题可能会困扰大家。其实是如 果你对Cookie有深入的理解,特别是对域和路径的概念比较清晰的话,就不会有问题了。 另外想提示的一点是request.ServerVariables("HTTP_COOKIE")得到Cookie和Request.Cookies得到的结果可能会有所不同。 ...

经验教程

504

收藏

6
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部