By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,855 Members | 1,988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,855 IT Pros & Developers. It's quick & easy.

prevent counter from incrementing when someone returns

P: n/a
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

Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> 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.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #2

P: n/a
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
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl...
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.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.