#1
  1. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Mar 2008
    Posts
    341
    Rep Power
    8

    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?

    Code:
    <% If Session("User_Restricted") > 0 Then %>
    
    Add 1 to Session("User_Restricted")
    
    <% ElseIf Session("User_Restricted") = 10 Then %>
    
    Do this
    
    <% Else %>
    
    Do nothing
    
    <% End If %>
  2. #2
  3. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,592
    Rep Power
    278
    like that
    Code:
    <% 
    If Session("User_Restricted") ="" then
          Session("User_Restricted") =0
    end if
    
    Session("User_Restricted")  = Session("User_Restricted")  + 1
    
    If Session("User_Restricted") = 10 Then 
           response.redirect "overLimit.asp"
    end if
    %>
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
  4. #3
  5. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Oct 2012
    Posts
    49
    Rep Power
    3
    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.
  6. #4
  7. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,592
    Rep Power
    278
    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...

Similar Threads

  1. Session in Page Load problems
    By akpaga in forum .NET Development
    Replies: 3
    Last Post: November 4th, 2010, 03:12 AM
  2. Passing session variable from login page..
    By captainzorro in forum ASP Development
    Replies: 0
    Last Post: March 27th, 2008, 02:28 PM
  3. Setting session variable when loading page..
    By peoplayer in forum ASP Development
    Replies: 2
    Last Post: May 2nd, 2006, 12:47 PM
  4. Replies: 3
    Last Post: May 9th, 2005, 05:32 AM
  5. How to load external web page into an array/variable
    By jnmunsey in forum ASP Development
    Replies: 3
    Last Post: April 20th, 2005, 02:24 PM

IMN logo majestic logo threadwatch logo seochat tools logo