Hit Counter / Session Problem

W

wetchman

Hey,

I've got a little counter program written to log individual hits to a page
without counting the same person twice. The problem is, it's counting the
same people twice. Here's the logic:

1) Check the session to see if they've been counted.
2) If they have not been counted:
- save their referrer/IP info
- flag their session to say they're counted
- end

But it seems that some people are being counted for every page they go to
and some are not. I've included the code below just in case. Is this a
server issue, a browser issue, a cookies/no cookies issue, or something
else? Any help would be much appreciated. I want to have accurate counts and
information for where people are coming from with as little effort as
possible.

Thanks

--
/bw



<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% DIM Referrer,RemoteIP,objConn,strConnect,FPath,adoStream

Referrer = lcase(Request.ServerVariables("HTTP_REFERER"))
RemoteIP = lcase(Request.ServerVariables("REMOTE_ADDR"))

'since we only want each hit per session to be counted, check to see if
they've been here yet
If isEmpty(Session(Referrer)) = TRUE OR Session(Referrer) <> TRUE Then

on error resume next

'insert our referrer information into this client's counts database
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("Counts.mdb") & ";User ID=;Password=;"

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect

strSQL = "INSERT INTO Counts (strReferrer,RemoteIP) VALUES ('" & Referrer
& "','" & RemoteIP & "')"

objConn.Execute(strSQL)
objConn.Close

'clean up our connection
Set objConn = Nothing

Session(Referrrer) = TRUE

End If

'now we stream back the 1 pixel image
FPath = Server.MapPath("spacer.gif")
Set adoStream = Server.CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(FPath)
Response.BinaryWrite adoStream.Read()
adoStream.Close: Set adoStream = Nothing
Response.End
%>
 
O

only me

users not having cookies enabled would he most obvious reason, add some code
on entry to check if user has cookies enabled or not and don't let them in
if not - that should at least eliminate that possibility.
 
W

wetchman

I thought it might take something like that - but are there any decent ways
besides BrowserHawk that can check browser capabilities on a single page or
easily determine who can accept cookies or not?

/bw
 
R

Randy R

I thought it might take something like that - but are there any decent
ways
besides BrowserHawk that can check browser capabilities on a single page or
easily determine who can accept cookies or not?

You can write a cookie to the client's machine and then attempt to read it.
If you can't retrieve a value, then their cookies are disabled.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top