Returing to original page after login

Discussion in 'JavaScript' started by smokeythebear, Dec 25, 2006.

  1. #1
    Hi,

    I use a simple login script for members which works fine. However, there are different pages from where they can launch the login process and instead of stipulating the page they alway go to after a sucessful login, I would like to send them back to the page they launched the login process from. Is that possible, I've attached a copy of the login script and the part where it redirects them to the home page instead of the page they were looking at just prior to the launch of the login process.

    'Admin and user functions
    '------------------------------------------------------------
    Const strLevel2Delete = "False" 'Allow level 2 members to delete other members?
    Const strLevel2Admin = "False" 'Allow level 2 members add/modify other members. NOTE, level 2 cannot delete members, or see there passwords. Default = True
    Const strLevel1Edit = "True" 'Allow level 1 members to modify their profile. NOTE, level 1 cannot change there login count, access levels, or anyother members. Default = True
    Const strAllowRegister = "False" 'Allow people to register? Change to to "No" if you dont want to allow registering. Default = True
    Const strAllowLogin = "False" 'Allow Login After Register? Change to to "False" if you dont want to allow login in after registering. Default = True
    Const strAllowDoubleUserNames = "False" 'Allow more than 1 users names to be the same? Change to "False" if you to allow double usernames. Default = False
    Const strAllowDoubleEmails = "False" 'Allow more then one unique email address to be the same? Change to "False" if you dont want to allow double emails for users. Default = False
    Const strRequireEmail = "True" 'Make the email address of each user required
    Const strLevel1Login = "../home/home.asp" 'Where the access level 1 (lowest member) is redirected to after login
    Const strLevel2Login = "admin_menu.asp" 'Where the access level 2 is redirected to after login
    Const strLevel3Login = "admin_menu.asp" 'Where the access level 3 (admin) is redirected to after login


    'Login pages
    '------------------------------------------------------------
    Const strLoginPage = "login.asp" 'Default Page for logging in. Default = login.asp
    Const strAuthorizedPage = "../home/home.asp" 'Authorized Page for after logging in. Default = authorised_user_page.asp
    Const strUnAuthorisedPage = "login.asp" 'Unauthorised Page for unauthorized users. Default = unauthorised_user_page.htm
    %>
     
    smokeythebear, Dec 25, 2006 IP
  2. pushkar

    pushkar Peon

    Messages:
    125
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this Response.redirect("login.asp") whe complete success Login...
     
    pushkar, Dec 25, 2006 IP
  3. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #3
    store the referring page's url in a session variable, and redirect there if succesfully logged in
     
    frankcow, Dec 25, 2006 IP
  4. weknowtheworld

    weknowtheworld Guest

    Messages:
    306
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think you can use to redirect the user to a different page :

    location.href="urpage.php";
     
    weknowtheworld, Dec 25, 2006 IP
  5. smokeythebear

    smokeythebear Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi there Frankcow - can you please tell me how I would store the referring page's url in a session variable....thanks for all ur help folks...a merry xmas to u all
     
    smokeythebear, Dec 25, 2006 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    Add a hidden field with the current URL in the login form, and use it's value to redirect later after loggin in.
     
    nico_swd, Dec 25, 2006 IP
  7. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #7
    if you're using PHP you can store session variables directly instead of using hidden form fields

    are you using PHP?
     
    frankcow, Dec 25, 2006 IP
  8. smokeythebear

    smokeythebear Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Noope - I'm using asp
     
    smokeythebear, Dec 26, 2006 IP
  9. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #9
    I guess ASP supports sessions as well...
     
    nico_swd, Dec 26, 2006 IP
  10. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #10
    ASP supports sessions variables just as well

    just set a variable like SESSION("returnTo")
     
    frankcow, Dec 26, 2006 IP