Use cookies to track users

Source: Internet
Author: User
Source Code:



<%

' * * * Keeping track of how many times
' * * * A user visits a Web page, by
' * * * * reading and writing cookies.

' * * * in this example "Asphole" would be
' * * * The name of our cookies, and
' * * * * "totalvisit" would be the ' key '
' * * * value we keep track of. You can
' * * * have multiple ' keys ' for each
' * * * cookies.

' * * * * Declare your variables
Dim Numvisit

' * * * Check to the many times they
' * * * * have been to your Web page.
Numvisit = Request.Cookies ("Asphole") ("Totalvisit")

' * * * If This is their The visit to
' * * * * The page numvisit is blank
' * * * 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 would
' * * * expire when the user closes their
' * * * browser, and you'll lose all info.
Response.Cookies ("Asphole"). Expires = "January 1, 2020"

%>




-end-


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.