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
%>
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
%>