473,804 Members | 2,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3711
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
3210
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 per server process, and the session data is not rewritten to disk. Explicitly calling session.save() (as stated in the doc) fails with the error message that a dictionary doesn't have the "save" attribute. Calling it as CGI sputs the log files with...
2
2029
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 on comp.lang.python crediting all those who contributed. <p> Here's what I've done so far - and where I get stuck: <p> 1. I made default installations of the latest versions: - apache_2.0.47-win32-x86-no_ssl.msi - mod_python-3.0.3.win32.exe
1
2294
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 the installer itself seems to be buggy -- in my case, no combination of mod_python 3.0.4, 3.1.2b and python 2.2.3, 2.3.3 ever came to completion. rather, the installer would exit -- after an initial declaration of having successfully found python...
2
1815
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 to use Python. I've installed mod_python (Debian libapache2-mod-python2.3, mod_python 3.1.3-4). My question is, how mature/stable is mod_python? Is it suitable for a production environment? The documentation is a bit lacking, and I've found...
0
1607
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 here is my code ..py s=Session.Session(req) s=user s.set_timeout(18000) s.save()
1
4363
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): req.content_type = 'text/plain' req.write("Under Construction")
2
3316
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 recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line
0
2053
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 (this might not be too smart, but I don't think it's related to my actual problem). I have a web application written on top of mod_python that uses cElementTree for several things. After installing cElementTree through
1
1301
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) It includes basic session and user management.
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.