Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to make vistor counter

    I want to make a vistor counter in asp language...

  • #2
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do a search through this forum, theres a lot of good examples using databases & text files.
    «Ðå G壣ꮻ²ºº²

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's a very simple one that uses FileSystemObject to write to a text file, that won't be incremented upon refresh (since it uses a session variable). It also creates the text file if it doesn't exist:

    http://www.solidscripts.com/displayscript.asp?sid=4

    Code:
    <%
    Dim cfs, cf, thefile, counter, sMapPath
    sMapPath = Server.MapPath("\")
    thefile = Mid(sMapPath, 1, InStrRev(sMapPath,"\")-1) & "\database\counter.txt"
    Set cfs = CreateObject("Scripting.FileSystemObject")
    If cfs.FileExists(thefile) Then
       Set cf = cfs.OpenTextFile(thefile, 1)
       counter = cf.ReadLine
    End If
    Set cf = cfs.OpenTextFile(thefile, 2, True)
    If Session("counted") <> "1" Then counter = counter + 1
    cf.WriteLine(counter)   
    Set cf = Nothing
    Set cfs = Nothing
    Session("counted") = "1"
    %>
    If you search with some diligence there are many other solutions here as well, I use a counter/logging script with an Access database on my website (I don't display any count on the page though) which keeps track of much more information in an access database (even whether or not users have javascript enabled - although from what I've gathered out of the statistics that really isn't of much use).
    Last edited by whammy; 02-18-2003 at 01:43 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •