Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 01:06 PM
Mike Brearley
Guest
 
Posts: n/a
Default prevent counter from incrementing when someone returns

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



  #2  
Old July 19th, 2005, 01:06 PM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: prevent counter from incrementing when someone returns

> my own graphics for the numbers), or is there a way to get this counter to[color=blue]
> increment only once per page per visit?[/color]

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/


  #3  
Old July 19th, 2005, 01:06 PM
Mike Brearley
Guest
 
Posts: n/a
Default Re: prevent counter from incrementing when someone returns

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" <aaron@TRASHaspfaq.com> wrote in message
news:elpDm2TMEHA.2276@TK2MSFTNGP09.phx.gbl...[color=blue][color=green]
> > my own graphics for the numbers), or is there a way to get this counter[/color][/color]
to[color=blue][color=green]
> > increment only once per page per visit?[/color]
>
> 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[/color]
carry[color=blue]
> around a sessionID in the session instead of all those tracking counters.
>
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>
>[/color]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles