Solved

Increment Session Counter on Click

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 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