Print Page | Close Window

login redirect

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6346
Printed Date: 31 March 2026 at 11:59am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: login redirect
Posted By: cuedog
Subject: login redirect
Date Posted: 11 October 2003 at 6:06pm
I want to know what I need to include in my login script to redirect the user back to the page they were trying to access.
For example, if a user wanted to access a directory with permission levels and they were not logged in they would be sent back to the login page and after they logged in they would be redirected back to the directory. I also want to make sure they are not redirected to an outside site if they had the directory bookmarked.
Can anyone help?


-------------
http://www.512ryders.com - 512 Ryders



Replies:
Posted By: God_Struth
Date Posted: 11 October 2003 at 6:45pm
Else If intForumID > 0 Then
                      Response.Redirect("forum_topics.asp?FID=" & intForumID)
                                              
'Return to forum homepage
                 Else
     Response.Redirect("default.asp ")
End If

-------------

Thats what I used from Login_user.asp

-------------
"I'm only trying to help......"


Posted By: cuedog
Date Posted: 11 October 2003 at 7:36pm
Thanks, but lets say someone has to login before they download an application and there is no intForumID then what do you do?

-------------
http://www.512ryders.com - 512 Ryders


Posted By: KCWebMonkey
Date Posted: 11 October 2003 at 11:34pm
you can find the URL of the refering page by using Request.ServerVariables("HTTP_REFERER")


Posted By: vshriniwasan
Date Posted: 12 October 2003 at 8:10pm

I am not 100% sure, but the HTTP_REFERER only keeps your previous page in memory. When you login, well thats two tries is involved and your refere has changed. I would just suggest just pass two values, section you are clicking the like, like Download, and the ID number you are clicking, then after logging in, just redirect to that page. The same way you can do it to different sections, just doing, select case statement.

Shrini



Posted By: KCWebMonkey
Date Posted: 13 October 2003 at 5:20pm
Originally posted by vshriniwasan vshriniwasan wrote:

I am not 100% sure, but the HTTP_REFERER only keeps your previous page in memory. When you login, well thats two tries is involved and your refere has changed.

that's why you store the page url in a variable and then pass it as a querystring to the next page...



Posted By: cuedog
Date Posted: 13 October 2003 at 10:14pm
Good ideas, one good way to do it would be to use the SCRIPT_NAME servervariable in the page that requires to be logged in and put it in a variable and pass it as a querystring back to the login page.

For Example:

<%
Dim strRefUrl
strRefUrl = Request.ServerVariables("SCRIPT_NAME")
If Request.Cookies("PollAdmin") = "" Then
Response.Redirect ("login.asp?ref=" & strRefUrl)
End If
%>


-------------
http://www.512ryders.com - 512 Ryders


Posted By: cuedog
Date Posted: 13 October 2003 at 10:22pm
I tried this out right after I posted this instead of before and it seems that HTTP_Referer will carry over the querystrings, but SCRIPT_NAME will not. So the code should be

<%
Dim strRefUrl
strRefUrl = Request.ServerVariables("HTTP_REFERER")
If Request.Cookies("PollAdmin") = "" Then
Response.Redirect ("login.asp?ref=" & strRefUrl)
End If
%>


-------------
http://www.512ryders.com - 512 Ryders



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net