使用Cookie来跟踪用户

王朝other·作者佚名  2006-11-24
宽屏版  字体: |||超大  

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-

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
>>返回首页<<
推荐阅读
 
 
频道精选
© 2005- 王朝网络 版权所有