[mod_python] session

Jim Gallacher jpg at jgassociates.ca
Fri Mar 17 15:47:33 EST 2006

stalker wrote:
> Hi, all!
> Is it possible to disable cookies generation by session?

I assume you are manually providing the session id by some other means, 
otherwise session will be non-functional.

You can't disable cookies with any of the current session classes. You 
could create a new subclass, and override the make_cookie method.

Alternatively you could try resetting the output headers after you 
create the session instance, but before writing any content. The 
following is not pretty but it should work.

def handler(req):
     req.content_type = 'text/plain'
     sess = Session.Session(req, sid=whatever)

     del req.headers_out['Set-Cookie']
     del req.headers_out['Cache-Control']
     req.write('all done')
     return apache.OK

Note that as of mod_python 3.2.8, the sid may only contain the 
characters 0-9 and a-f, and len(sid) must equal 32.


More information about the Mod_python mailing list