Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    18

    Unanswered: redirecting urls

    lets say the user has clicked on the edit personal profile page, but hes not being logged in, thus he will be redirected back to the login page.

    and after the user has logged in, i need to redirect the user back to the ORIGINAL page which the user wanna view, in this case it'll be the edit personal profile page.

    may i know how do i go about doing the redirecting user back to the original page?

    many thanks in advance. =)

  2. #2
    Join Date
    Jan 2005
    Posts
    36
    You could do something like this.

    When the user hits the restricted page and gets bumped back to the login page, you probably are checking a session variable, something like this

    if session("loggedin") <> 1 then response.redirect "login.htm"

    You could add to it

    if session("loggedin") <> 1 then
    session("attemptedpage") = "editprofile.asp" //you would change this for different pages
    response.redirect "login.htm"
    end if

    then in your login check pages, check for that session variable

    // logged in successful
    session("loggedin") = 1
    if session("attemptedpage") <> "" then
    response.redirect session("attemptedpage")
    else
    response.redirect "usualloginpage.asp"
    end if
    Last edited by DrewM; 01-28-05 at 03:39.

  3. #3
    Join Date
    Dec 2003
    Posts
    454
    The following code will redirect the user to the page she/he comes from.

    Response.Redirect "../login/login.asp?redir=" & Server.URLEncode(Request.ServerVariables("PATH_INF O"))

  4. #4
    Join Date
    Jan 2005
    Posts
    36
    thats not what he asked - won't work for what he wants to do.

  5. #5
    Join Date
    Dec 2003
    Posts
    454
    Quote Originally Posted by devonnicious
    lets say the user has clicked on the edit personal profile page, but hes not being logged in, thus he will be redirected back to the login page.

    and after the user has logged in, i need to redirect the user back to the ORIGINAL page which the user wanna view, in this case it'll be the edit personal profile page.

    may i know how do i go about doing the redirecting user back to the original page?

    many thanks in advance. =)
    First, you need to check if the user is logged in. If not, you can redirect the user to Login page. Here is the example. In your EditProfile.asp page, you can add the following code at the beginning of the code:

    <%
    If Session("UserID") = "" Then
    Response.Redirect "../login/login.asp?redir=" & Server.URLEncode(Request.ServerVariables("PATH_INF O"))
    End If
    %>

    In your Login.asp, you can catch the value of redir and then pass it to LoginProcess.asp page.
    <form action="LoginProcess.asp" method="post">
    <input type="hidden" name="redir" value="<%= Request("redir") %>">
    ......
    </form>

    In your LoginProcess.asp, you need to redirect the user to EditProfile.asp page if login is successful.

    If Request("redir") <> "" Then
    Response.Redirect Request("redir")
    Else
    ' go to the page you want
    End If
    %>

  6. #6
    Join Date
    Mar 2004
    Posts
    18
    yup yup. everything's working now. thanks alot dudes !

    and by the way, im not a HE. im a SHE. *winks* heh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •