html5中文学习网

您的位置: 首页 > 网络编程 > ASP编程 » 正文

使用Cookie来跟踪用户_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-
U8WHTML5中文学习网 - HTML5先行者学习网
U8WHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助