Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Direct user to correct page upon login...help

    I've created a secure login site. Everything works fine except for one thing... the redirect.

    I want to redirect users to the correct page they are accessing (say they're just clicking a link they've bookmarked to a particular page in the secure site) rather than forcing them to navigate in from a default "login successful" page.

    In each secure page, I have this include file:

    <%
    if Session("valid") = "" Then
    Response.Redirect ("login_new.asp?r=" & Server.URLEncode(Request.ServerVariables("URL") & Request.Querystring))
    end if
    Session.Timeout=120
    %>

    My login script looks like this:

    <form name="login" method="POST" action="verify_new.asp">
    <p>Username:
    <input type="text" name="UserName">
    </p>
    <p>Password:
    <input type="password" name="Password">
    </p>
    <p><input type="hidden" name="redirect" value="<%=Request.Querystring("r")%>">
    <input type="submit" name="Submit" value="Submit">
    </p>
    </form>

    My verify page looks like this:

    <%
    dim username, password, sRedirect

    sRedirect = Request.Form("redirect")
    If sRedirect = "" then
    sRedirect = "default.asp"
    end if

    ...(lots of code)...

    ' if both username and pass are valid, create session ID
    if Session("Valid") = Request("username") then
    response.redirect sRedirect
    end if
    %>

    If I create a url like this: http://www.mywebsite.com/youarehere.asp, everything functions just fine. However, if I create a url like this: http://www.mywebsite.com/inthisfolder/youarehere.asp the script always returns a page cannot be found error.

    I've looked through my code, but I don't see that I've coded a bum link.

    The error url returned looks like this: http://www.mywesite.com/login_new.as...uarehere%2Easp

    And, it's a simple 404 error.

    I suspect it has something to do with how I create the stored url in this line:
    Response.Redirect ("login_new.asp?r=" & Server.URLEncode(Request.ServerVariables("URL") & Request.Querystring))

    Any thoughts or suggestions?

    Thanks,

    Culley

  • #2
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, I'm dumb, I figured it out.

    I just spelled out the full url path to the login_new.asp file.

  • #3
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just a note;
    You need a little validation on your URL.

    Code:
    If Request.ServerVariables("QueryString") <> "" Then
     qs = "?" & Request.ServerVariables("QueryString")
    End If
    url = Request.ServerVariables("URL") & qs


  •  

    Posting Permissions

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