?
Solved

Increment Session Counter on Click

Posted on 2006-06-09
3
Medium Priority
?
612 Views
Last Modified: 2012-08-13
I have a site where I display training images to a user. The images are named as such:

topic1_1.jpg
topic1_2.jpg
topic1_3.jpg
etc.....

When the user clicks the Next link at the bottom of the page I need to invoke code that increments the Session("Counter") by 1.

I have this now:

<% Session("Counter") = Session("Counter") + 1 %>

But the problem is when I refresh the page the counter increments. I only want it to increment when the user clicks the next button.

Any ideas on how I can make this happen?

This is my current link:
<a href="topic_view.asp?ImgNumb=<%=Session("Counter")%>&TrainingId=<%=Session("TrainId")%>">
<img src="/images/next.gif" border="0"></a>

Thanks in advance for your help,
Curtis
0
Comment
Question by:rcmb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
peh803 earned 2000 total points
ID: 16872909
Curtis:

You can send the user to an intermediate page to do the incrementing ...

So, it'd be something like this:

<a href="increment_and_redirect.asp?ImgNumb=<%=Session("Counter")%>&TrainingId=<%=Session("TrainId")%>">
<img src="/images/next.gif" border="0"></a>

then, on increment_and_redirect.asp page, you'd have code to increment the counter, and then redirect to the image that you tell it to.  In that way, you wouldn't have any problems with incrementing each time the user refreshes the page, because the incrementing happens on a "middle" page.

Hope that makes sense!

Regards,
Phil
0
 
LVL 12

Author Comment

by:rcmb
ID: 16872975
Good idea - that works just fine.

Thanks - Phil


Regards,
Curtis
0
 
LVL 19

Expert Comment

by:peh803
ID: 16873211
Glad to help!

Regards,
Phil
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question