Solved

Increment Session Counter on Click

Posted on 2006-06-09
3
555 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
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
peh803 earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now