473,811 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("objCou ntFile") <> iCount then
iCount = iCount + 1
Session("objCou ntFile") = 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
2 2001
> 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
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***@TRASHasp faq.com> wrote in message
news:el******** ******@TK2MSFTN GP09.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5874
by: Earl Anderson | last post by:
KB Article Q140908 provided the following function to create an Auto Incrementing Counter: Function Next_Custom_Counter () On Error GoTo Next_Custom_Counter_Err Dim MyDB As Database Dim MyTable As Recordset Dim NextCounter As Long
3
3790
by: Dirk Reske | last post by:
Hello, I have following code:
9
4047
by: Daniel Vukadinovic | last post by:
I want to implement an index/counter to my linked list. Why? I wrote a search function which searches the list for elements based on their values (say I add an element and I assign the value 54 and the next element 789 and so on...) now I'd like to write a search function which would search the list for elements based on their index. Say first element is 54 and index 1, second element is 789 and index 2 so when I want to search, I'll do...
13
9843
by: technocraze | last post by:
Hi guys, I have an issue with incrementing a counter in a table using VB in MS Acess environment. Below mentioned is an instance. Implementation logic Table fields Serialno = pk Datatype text StudentId Text Course Text
3
10132
blackstormdragon
by: blackstormdragon | last post by:
Here were our instructions: "My mother always took a little red counter to the grocery store. The counter was used to keep tally of the amount of money she would have spent so far on that visit to the store if she bought everything in the basket. The counter had a four-digit display, increment buttons for each digit, and a reset button. An overflow indicator came up red if more money was entered than the $99.99 it would register. (This was a...
4
3338
by: WEG | last post by:
I want to create a custom counter to act as the primary field in a table but am having trouble with it. What I would like is a counter that shows the last two digits of the year, a hyphen, then a counter that starts at one and goes up by one digit with each new record. Then, when a new year starts, would reset to one and start again. For instance, 07-001, 07-002 and so on until 08-001, 08-002. I've seen all kinds of great answers...
1
1641
by: senger.kim | last post by:
Hello World, I'm relatively new to MS Access (2003) and am trying to implement something that I feel should be simple but cannot find a solution. Hoping that you can help me or point me where to seek more help. Let's start with a hypothetical database: ID Name 1 Peter
2
1955
by: NJonge01 | last post by:
Hi, I use a counter in a subreport. The subreport is the primary data presentation for the report, and it covers more than 1 page. I use the OnFormat event of the Detail section to conditionally initialize the counter. I use the Onprint event of the Detail to increment the counter. The problem is, that the counter seems to initialize itself when the report is pushed to a new page. The response is different if I have the "Keep...
30
2859
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 IsEmpty(Session("TotalCount")) Then ' Increment or reset the count If Weekday(Date(),vbSunday) = 1 And dtDate <Date then
0
9728
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10648
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10402
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10135
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.