How can I do this in Python?

L

Lad

Hi,
I have a web program and a user can have access to a page only after he
logged in.
So, the program comes with a Login form and the user logins.But I do
not know how to return the user back to where he came from, after a
successful login.

Something like this:

PageWhereUserMustBeLogin -------->UserSigned----->-

^------<---------------------------------------------------<----|


Thank you for help

L.
 
D

David Wahler

Lad said:
Hi,
I have a web program and a user can have access to a page only after he
logged in.
So, the program comes with a Login form and the user logins.But I do
not know how to return the user back to where he came from, after a
successful login.

Something like this:

PageWhereUserMustBeLogin -------->UserSigned----->-

^------<---------------------------------------------------<----|


Thank you for help

L.

You'll need to either use a hidden form field or check the HTTP
"Referer" header to determine the page the user was on. Then, just use
an HTTP redirect to send them back to that page.

Are you using a particular web application framework, or separate CGI
scripts?

-- David
 
S

Steve Holden

David said:
You'll need to either use a hidden form field or check the HTTP
"Referer" header to determine the page the user was on. Then, just use
an HTTP redirect to send them back to that page.

Are you using a particular web application framework, or separate CGI
scripts?
Another alternative might be to serve a script that sent the browser
back 2 pages in its history, as long as server state hasn't changed in
the meantime.

regards
Steve
 
L

Leif K-Brooks

Steve said:
Another alternative might be to serve a script that sent the browser
back 2 pages in its history, as long as server state hasn't changed in
the meantime.

What about users with JavaScript disabled?
 
J

jgardner

I strongly suggest using redirect as David Wahler suggested.

A note, Mozilla type browsers don't do an excellent job sending
referer. You can't really trust that header anymore. If you want to go
back after login, either:

(1) Render the login page INSTEAD of the normal content at the same
url. Form submission would go back to the same page not requiring a
login; plus, you could pick up the URL and paramters on the login page.

(2) Have the page requiring login redirect with extra parameters that
describe the page URL and the parameters needed to access it properly.
HOWEVER, you need to be careful that you don't allow any old URL there,
because someone else could have your logged in user redirect to their
site.
 

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

Forum statistics

Threads
474,270
Messages
2,571,341
Members
48,031
Latest member
rashmi16

Latest Threads

Top