467,145 Members | 956 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,145 developers. It's quick & easy.

mod_python and PHP sharing same session

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

Apr 3 '06 #1
  • viewed: 3466
Share:
2 Replies
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.


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
Apr 3 '06 #2
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

Apr 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Markus Schaber | last post: by
1 post views Thread by wolf | last post: by
2 posts views Thread by Dan | last post: by
reply views Thread by wafd Alex | last post: by
1 post views Thread by treelife | last post: by
2 posts views Thread by exhuma.twn | last post: by
reply views Thread by Manuzhai | last post: by
1 post views Thread by Jan Danielsson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.