473,287 Members | 1,643 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

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
2 3683
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Markus Schaber | last post by:
Hi, Does anybody know a module that works with Apache 1.3 mod_python and provides session tracking? I tried pso, but this didn't work as it should. Running in mod_python gives me one session...
2
by: Rolfe | last post by:
Has anyone had success getting mod_python to run on Apache on Win2K? I'm writing up instructions on how to do this and need your help. When completed, the instructions at the mod_python website and...
1
by: wolf | last post by:
i would like to briefly share my experiences with installing mod_python on a w2000 box. i must say that i believe the installation process to be unnecessarily complicated by the simple fact that...
2
by: Dan | last post by:
I've been writing a server application in Python. The app listens on a socket and interfaces to a database. Now I'd like to write a web application to also access the database. It seems natural...
0
by: wafd Alex | last post by:
hi all when i use Session object to save a object and then i use util.redirect(req,url) to redirect a .psp.But in my psp i cann't load session so i cann't get object from session,help me,thanks...
1
by: treelife | last post by:
I'm getting and internal server error when | run the following mod_python script. I am actually trying to run Django. Script: from mod_python import apache def handler(req):...
2
by: exhuma.twn | last post by:
Hi again, as soon as I try to make use of the "session" object inside a psp-template file, I get the following error: Mod_python error: "PythonHandler mod_python.publisher" Traceback (most...
0
by: Manuzhai | last post by:
Hello there, I have this weird problem with a mod_python application. Recently I installed ElementTree and cElementTree through ez_setup.py, even though they were already installed normally...
1
by: Jan Danielsson | last post by:
Hello all, I have written a web-based voting system (add question, add possible answers to that question, and let users vote) in python. It uses: - mod_python - postgreql (through psycopg2) ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.