By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,548 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,548 IT Pros & Developers. It's quick & easy.

How can I do this in Python?

P: n/a
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.

Nov 4 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Lad wrote:
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

Nov 4 '05 #2

P: n/a
David Wahler wrote:
Lad wrote:
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?

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
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Nov 4 '05 #3

P: n/a
Steve Holden wrote:
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?
Nov 4 '05 #4

P: n/a
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.

Nov 4 '05 #5

P: n/a
Lad
Can you please explain in more details (1) choice?
Thanks
Regards,
L

Nov 5 '05 #6

P: n/a
Lad wrote:
Can you please explain in more details (1) choice?


If you are using CGI you might be interested in the VoidSpace logintools which seems to handle much of this process. See
http://www.voidspace.org.uk/python/l...ogin-no-access

Kent
Nov 5 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.