Solved

Increment Session Counter on Click

Posted on 2006-06-09
3
565 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Classic ASP - problem with MS SQL Select Query? 10 61
Record locking on classic ASP 3 40
Table header must be on top 2 29
GitHub 1 10
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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