473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can I do this in Python?

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
6 1208
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
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
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
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
Lad
Can you please explain in more details (1) choice?
Thanks
Regards,
L

Nov 5 '05 #6
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Olaf Meyer | last post by:
I'm having some problems compiling Python 2.3.3 on HP-UX (B.11.00). I've tried sevral different options for the configure script (e.g. enabling/disabling gcc, aCC) but I always get the same problem...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 259 open ( -5) / 2573 closed (+17) / 2832 total (+12) Bugs : 745 open ( +0) / 4405 closed (+21) / 5150 total (+21) RFE : 150 open...
1
by: Jerald | last post by:
Running python 2.3.4 on valgrind (a tool like purify which checks the use of uninitialized memory, etc), gives a lot of errors. See below. jfj@cluster:~/> python -V Python 2.3.4...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 241 open ( -6) / 2622 closed (+26) / 2863 total (+20) Bugs : 764 open ( +6) / 4453 closed (+38) / 5217 total (+44) RFE : 150 open...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 391 open ( +7) / 3028 closed (+12) / 3419 total (+19) Bugs : 906 open ( -3) / 5519 closed (+19) / 6425 total (+16) RFE : 207 open...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 420 open ( +4) / 3410 closed ( +2) / 3830 total ( +6) Bugs : 915 open (+17) / 6186 closed ( +6) / 7101 total (+23) RFE : 235 open...
11
by: Osiris | last post by:
I have these pieces of C-code (NOT C++ !!) I want to call from Python. I found Boost. I have MS Visual Studio 2005 with C++. is this the idea: I write the following C source file:...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.