redirect to correct page

S

shank

I have a few pages that require login to access. Assuming a user clicks a
link containing a variable trying to access a password protected page. That
user is redirected to the login page. After login, he's brought to a "logged
in" page. How do I retain the original link he clicked and instead of
redirecting to a logged in page, he's redirected to the page he originally
requested?

(hope that makes sense...)
thanks
 
R

Ray at

In the include that checks if the user is logged in:

If Session("loggedin") = "" Then
Response.Redirect "login.asp?r=" &
Server.URLEncode(Request.ServerVariables("URL") & Request.Querystring)
End If


login.asp:

<input type="hidden" name="redirect" value="<%=Request.Querystring("r")%>">

On the page that validates login:

sRedirect = Request.Form("redirect")
If sRedirect = "" Then sRedirect = "yourdefaultpage.asp"


Untested

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top