mod_python and PHP sharing same session

S

Scott

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
 
D

Diez B. Roggisch

Scott said:
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.

Where did you read that? I seriously doubt that - simply because the
internal representations of data stored in sessions are most likely
incompatible between python and php - not sure what mod_pythonuses, but I
guess pickle. And php will use whatever php uses.

So - if you already know the session file, you'd might be able to parse it
yourself. Alternatively, you might consider using cookies for the shared
state.

Diez
 
J

Jim Gallacher

Scott said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top