Re: The prefered 'login' procedure and redirect.
From: Chung Leong (chernyshevsky_at_hotmail.com)
Date: 03/25/05
- Next message: Brent Palmer: "Re: Display a friends name when searched for by phone number"
- Previous message: leegold: "Looking for jumping pager for MYSQL"
- In reply to: Simon: "The prefered 'login' procedure and redirect."
- Next in thread: Simon: "Re: The prefered 'login' procedure and redirect."
- Reply: Simon: "Re: The prefered 'login' procedure and redirect."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 25 Mar 2005 02:15:16 -0500
"Simon" <spambucket@myoddweb.com> wrote in message
news:3af6kuF68kv59U1@individual.net...
> Hi,
>
> I have a Login.php page that logs the user in and out.
> I has two forms within the page, (depending on what we are trying to do),
> either one to log in or out.
>
> The form calls itself using a post method and either logs the user in our
> out given the information from the form.
> but every pages use sessions and cookies, if the user is successfully
logged
> in then the cookies and session values are updated, (as well as MySQL).
>
> Now it all works fine but I want to add some functionality where if the
user
> goes to a restricted page they are sent to the login page, and if the
login
> is successful then they will be sent back to the original restricted page.
>
> I can redirect the user from the restricted page to the login page, but
> returning to the restricted page after login is a problem as the headers
> have been sent already, (to do the login).
> Because the login uses sessions/cookies and tables I have to send the
> headers to do the login as I cannot login the user and then redirect them
to
> a page, (the redirect must be before sessions/cookies I believe.
>
> So what is the 'preferred way to redirect users after a successful login?
When a user access a restricted page and he/she is not logged in, redirect
him/her to the login page with the requested uri in the URL. The login page
writes the request uri in a hidden field along with fields for user name and
password. When authentication/authorization is successful, the post handling
code of the login page redirects to the request uri. If not, the login page
redirects to itself.
Redirect can happens after the session is set, since it's just an HTTP
header. There's no problem simultaneously setting a cookie and redirecting
the browser.
- Next message: Brent Palmer: "Re: Display a friends name when searched for by phone number"
- Previous message: leegold: "Looking for jumping pager for MYSQL"
- In reply to: Simon: "The prefered 'login' procedure and redirect."
- Next in thread: Simon: "Re: The prefered 'login' procedure and redirect."
- Reply: Simon: "Re: The prefered 'login' procedure and redirect."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|