prevent counter from incrementing when someone returns

M

Mike Brearley

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 session. The problem is, it
also prevents other page counters from incrementing. Here's the code for
this part:

' Increment the count
if Session("iCount") <> iCount then
iCount = iCount + 1
Session("iCount") = iCount
end if

I changed iCount to another variable used within the code, and it works for
allowing other page counters to increment, but also increments a page you
already visited if you re-visit it and hit refresh.

' Increment the count
if Session("objCountFile") <> iCount then
iCount = iCount + 1
Session("objCountFile") = iCount
end if

The main code for the counter in on www.faerybug.com/counter.asp. I use an
include statement, <!-- #INCLUDE FILE="./counter.asp" --> to put the counter
on a page.

Is there something better I should use or look at (want the option of using
my own graphics for the numbers), or is there a way to get this counter to
increment only once per page per visit?

Thanks!!

--
Posted 'as is'. If there are any spelling and/or grammar mistakes, they
were a direct result of my fingers and brain not being synchronized or my
lack of caffeine.

Mike Brearley
 
A

Aaron Bertrand - MVP

my own graphics for the numbers), or is there a way to get this counter to
increment only once per page per visit?

You need a counter per page. I recommend handling this in a database, and
only incrementing each page once per sessionID. Then you only have to carry
around a sessionID in the session instead of all those tracking counters.
 
M

Mike Brearley

Could you explain how to do that? I'm fairly new to this.

--
Posted 'as is'. If there are any spelling and/or grammar mistakes, they
were a direct result of my fingers and brain not being synchronized or my
lack of caffeine.

Mike Brearley
 

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

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top