Solved

Increment Session Counter on Click

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
IIS POST request being ignored 4 46
Random function on ASP page not working 6 47
Syntax Help on SP 4 52
XML Parsing Classic ASP 5 42
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…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

17 Experts available now in Live!

Get 1:1 Help Now