mod_python and PHP sharing same session
Jim Gallacher
jg.lists at sympatico.ca
Mon Apr 3 11:33:46 EDT 2006
Scott wrote:
> I am trying to get a mod_python application to read an existing PHP
> session. I need some data that was set in the session by the PHP
> application. I am using the mod_python Session class but even when I
> specify the session id that PHP uses the Sesssion(req, sid) call
> returns a new session id. The session file exists in /tmp as
> mp_sess.dbm and I have verified that PHP is reading/writing it and from
> what I have read mod_python will use the same file. I have used the
> PythonOption session DbmSession in the Apache configuration to force
> this and specified the filename as well but to no avail.
>
> Has anyone attermpted what I am trying to perform and if so a short
> snippet of code or explanation of how to interface to PHP session via
> mod_python would be great. I am not an experiecne PHP users but have
> used mod_python extensively.
> Scott
It shouldn't be a suprise that this doen't work. Mod_python stores its
session data as a python pickle. PHP stores its session data as... well
I have no idea, but I'm pretty sure it won't be a python pickle. ;)
Mod_python creates a new session if it can't load valid session data
from the dbm file, which will always be the case here as that file
contains PHP formatted session data.
You have 2 choices: Rewrite PHP session handling to write the data as a
python pickle, or subclass mod_python BaseSession to read the PHP data
format. Once that's done you'll need to figure out how to handle
session locking between the 2 modules, which may not be trivial.
I'd suggest joining the mod_python mailing list if you want to discuss
this in detail.
Jim
More information about the Python-list
mailing list