[mod_python] The right way to handle sessions

Fabio Rotondo mlists at rotondo.it
Thu Aug 12 15:48:24 EDT 2004


Amir Salihefendic wrote:
> Hello.
> I welcome myself to this list ;-)
> 
> I have a question about how to handle sessions correctly.
> I am creating a simple login system (just messing around with mod_python).
> Let's say that we have a page called index.py and we are using the 
> publisher handler.

Hi,

try this code: ``req`` is the request object from mod_python.

def get_session ( req ):
	sess = Session.Session  ( req )

	if sess.is_new ():
		sess.save ()
	else:
		sess.load ()

	return sess

Ciao,

   Fabio


More information about the Mod_python mailing list