[mod_python] session example

Richard Barrett r.barrett at ftel.co.uk
Tue Apr 6 11:25:14 EST 2004


On 6 Apr 2004, at 11:02, John Mudd wrote:

> I may be way off so feel free to correct me but here what I've come to
> believe.  It's necessary to write cookies before any other writes.  So
> you need to save the session (which writes it's cookie) before any 
> other
> writes.
>

Could that be because the cookie has to go in the response header and 
starting to write the response body "flushes" the response headers in 
whatever state they are in at that point, as they must precede the 
body, and thus any subsequent header changes  are in effect lost?

> John
>
>
> On Tue, 2004-04-06 at 04:13, pascalbarbedor at free.fr wrote:
>> hi
>> thanks for preceeding answer but I cant make it work.
>>
>> what's wrong with this:
>> ---------------------------------------
>> sess=Session.Session(req)
>>
>> if sess.is_new():
>>     req.write(sess.id())
>> else :
>>     req.write('used session %s'%sess.id())
>>
>> sess['login']='toto'
>>
>> req.write("%s"%sess)
>>
>> sess.save()
>> ----------------------------------------
>>
>> shouldn't it display session used on second reload of the page ?
>>
>>
>> thanks
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>



More information about the Mod_python mailing list