February 11th, 2013, 02:49 AM
Incrementing a session variable on page load
Can anyone tell me how I might be able to increment a session variable by 1 each time a page loads. I want to find a way to keep track of how many times a user accesses a set of pages then once they have reached a certain number to be able to re-directed them elsewhere. I have an idea to put something like the code below on each page but am not sure how to make the session variable increment?
<% If Session("User_Restricted") > 0 Then %>
Add 1 to Session("User_Restricted")
<% ElseIf Session("User_Restricted") = 10 Then %>
<% Else %>
<% End If %>
February 11th, 2013, 12:26 PM
If Session("User_Restricted") ="" then
Session("User_Restricted") = Session("User_Restricted") + 1
If Session("User_Restricted") = 10 Then
if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
February 12th, 2013, 01:08 AM
The thing is if someone closes the browser they can go back for 10 more views. I gather you want something like Plenty of Fish where you can view profiles xx number of times and then for the next 15 minutes are redirected to one page (in the POF case a Signup page).
I had such a script written before, it logged the IP addresses in a database and purged them after 15 minutes. Alas the code is long gone but it's certainly not difficult to do if you need code samples.
February 12th, 2013, 08:14 AM
in this case would be better to set cookies with number of retries and last retry time. and work on that. logging ip addresses did not give you actual computer. If it is from local network all computers will have the same ip... So you count attempts not from computer, but from router...