473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Hit Counter / Session Problem

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,adoStre am

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
%>
Jul 19 '05 #1
3 4445
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.

"wetchman" <we******@NOSPAMhotmail.com> wrote in message
news:Xg*********************@news.alltel.net...
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,adoStre am

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

Jul 19 '05 #2
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
"only me" <on*****@hotmail.com> wrote in message
news:qp********************@newsfep4-glfd.server.ntli.net...
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.

"wetchman" <we******@NOSPAMhotmail.com> wrote in message
news:Xg*********************@news.alltel.net...
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,adoStre am

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


Jul 19 '05 #3
> 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.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: alfa_beveren | last post by:
How to make a simple Hit Counter ? I am old VB Programmer, trying to learn ASP... alfa_beveren@hotmail.com
2
by: Mike Brearley | last post by:
I have a counter (alright one I found on asp101.com) that checks for a session variable to prevent the counter from incrmenting if a user refreshes the page or returns to the page during the same...
0
by: Coco | last post by:
I have a active user counter in my web apps which previously works but now i realise the counter keep increasing. the value of active user is kept in the global.asax which i do increase during...
1
by: Mark | last post by:
I know I've seen an example of this, but can't seem to find it (I thought it was in my copy of 'ASP.NET Uleashed?). I want to use session_start in my global.asaax file to update a hit counter...
9
by: Kenny M. | last post by:
I want to control how many users there are login in my app I have the following code on Session_Start Application.Lock(); Application = int.Parse(Application.ToString()) + 1;...
1
by: zenfor | last post by:
Hi, I have a simple script I found that increments a number in a text file. I was wondering if anyone has a routine that will commify the number. Thank you! =============== <% counter_file...
30
by: Paul W Smith | last post by:
I have written a hit counter, which I believe counts the times my page is hit by a user for each unique session by the user. The relevant part of my code is below: If...
3
by: tedpottel | last post by:
Hi I cannot get sessions to work. I have the following code </body> <? session_start(); $counter++; print "You have visited this page $counter times during this session";...
4
by: ndedhia1 | last post by:
I am reading in a file to see what delays I am getting on what IP address: QuoteBlockTiming exceeded 1000 ms: 1684 --- Fri Nov 06 06:09:10 CST 2009 170.137.94.95 Class key = 649126730 block...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.