Click to See Complete Forum and Search --> : Seesions/Login


jrthor2
08-13-2003, 11:16 AM
I have an admin site where when logging in, it sets session variables that expire after 20 minutes of inactivity. If a user is inactive and then clicks a link, they go back to the login page to login again. Is it possible, after they re-login, to take them to the link they clicked on?

bloke
09-01-2003, 08:51 AM
In the file that checks for the session variable, grab the originating page using http_referer, perhaps store that in another sessions variable, then when the user successfully logs back in, response.redirect to the originating page.

TBor
09-02-2003, 08:48 AM
What I do on my page is use the global.asa file. In the Session_OnStart section, I have the following code:

LoginPage = "login.asp"
CurrentPage = Request.ServerVariables("SCRIPT_NAME")
Session("RequestedPage") = CurrentPage

If strcomp(CurrentPage,LoginPage,1) Then
Response.Redirect(LoginPage)
End If

Basically, it sets your login page to "login.asp" and grabs the requested page and stores it in a Session variable "RequestedPage". The strcomp command redirects the user to the login page if the requested page is not the login page already.

At the end of login.asp, once the login is processed, you can use response.redirect to send the user to the page specified in Session("RequestedPage").

You may need to play around a bit with how you pull the requested page from ServerVariables (I had to add some additional code that I haven't shown here to deal with querystrings in the requested page), but the basic idea here works.

Hope this helps,
TBor