|
Terry MacDonald
terry.macdonald at dsl.pipex.com
Wed Sep 22 15:50:30 EDT 2004
If is_new() is always true it means that a session cookie is not in the
request.
util.redirect does not set up the cookie in the response, calling
Session(req, secret...) does that (if the request does not have a valid
one already set)
Not knowing what is going on in your login script its hard to tell what
the exact problem is but I would check that session cookies are being
exchnged between the browser and the server.
On Wed, 2004-09-22 at 01:12, Todd Boland wrote:
> Hello again!
>
> In my experiences as a web developer (I'm coming from a Perl/Mason
> environment), I've found that the convenience of "transparently"
> generating sessions outweighs the performance hit.
>
> I'm trying to implement sessions "transparently" using 2 handlers for
> every request. The first handler makes sure a session is set, if it was
> just created, it will forward the browser to a login page (like the
> documentation suggests). More code that checks session ids against
> values in the database to authenticate users will eventually be added.
>
> By the time a request gets to the second handler (the Publisher
> handler), sessions have preemptively been taken care of (it's totally
> "transparent").
>
> The problem I'm having is: I end up in an infinite redirect loop:
>
> The session handler:
>
> from mod_python import apache, util
> from mod_python.Session import Session
> from RPM.common import web_root
>
> def handler(req):
> session = Session(req, secret='********')
>
> # if the session is new, they need to log in
> if session.is_new():
>
> # Using util's redirect will set the cookie
> util.redirect(req, web_root('index.py/login?url=%s' %
> req.uri))
>
> # TODO: Make sure sid is logged in
>
> # Hand off to Publisher handler by returning 200 OK
> return apache.OK
>
> session.is_new() always returns 1 even after the session cookie is set
> (after the redirect). Any ideas or nudges in the right direction would
> greatly be appreciated. Thanks!
--
Terry
Registered Linux User # 311806
www.taumu.com
|