View Full Version : Returing to original page after login

12-25-2006, 10:56 AM

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

12-25-2006, 11:28 AM
You need to check the referer header (URL of the previous page, if any).
Should be something like:

On login.asp you should have a hidden form field with the referer value.
When submitted you should redirect user to that page (in case referer is not empty of course).