473,385 Members | 1,593 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,385 software developers and data experts.

Stange behaviour: PHP5.2.4 userdefined Sessionhandler in write function

Hi group,

I found something strange in PHP5.2.4 (on IIS7/Vista).

I am working on an app that has been running just fine under heavy load
for over a year at some custumer of mine. (they have PHP5.1 on W2003
Server, ISAPI)

I imported the whole project locally on a slightly more modern version
of PHP 5.2.4 to make a few adjustments.

I needed a custum sessionhandler (via database) in this particular project.

So I have:

session_set_save_handler (
'MySession_open',
'MySession_close',
'MySession_read',
'MySession_write',
'MySession_destroy',
'MySession_gc');

First thing I found locally was that my sessions didn't work.

After some errorlogging (which is not easy in sessionhandlers since you
cannot output via echo to the client, you need to debug via a file), I
found the reason for my trouble was the fact that I lost my $connection
object.

This object is a ADODB object (www.phplens.com/adodb).
I used this particular databaseabstraction layer for years without problems.

Here is the start of my modified session write handler function:

function MySession_write($ses_id, $data) {
global $connection;

$connExists = (isset($connection) ? "exists": "doesn't exist");

// Hack for my version of PHP that somehow destroys connection
if (!isset($connection)){
require ('dbconnect.php');
}

error_log("\ninMySession_write:\$connExists=".$con nExists."\n\$ses_id=$ses_id\n\$data=$data\n\n",3,' C:\inetpub\php5errlog.txt');

..... actual code ...
}

I was surprised to find in C:\inetpub\php5errlog.txt:
in MySession_write:$connExists=doesn't exist
$ses_id=d86415c53f9c9f4125cff6b2725eb61e
$data=userid|i:1;realname|s:18:" CS-Erwin Möller";isadmin|s:1:"Y";

Meaning my $connection was lost somewhere.
I use that same approach (via global $connection) in all other
sessionhandler functions. No problems.
But in the writeroutine it is gone.

This for sure DIDN'T happen on the earlier version of PHP5 at my client.

Thus I ended up adding this stinking piece of code, to re-include the
whole databaseconnection-code:

// Hack for my version of PHP that somehow destroys connection
if (!isset($connection)){
require ('dbconnect.php');
}

Any ideas what is causing this?

I was thinking that PHP was maybe clearing up its connections to the
database first, before calling the session_write routine? Thus
invalidating my $connection? (I am guessing here).

Did anybody see something similar?
Any clues?

Regards,
Erwin Moller
Sep 19 '07 #1
0 1375

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Philipp Lenssen | last post by:
OK, I can get PHP5 running on Apache 2 installed on Windows XP Home Edition. Now I want to add MySQL4 to the package. I installed it but I'm not sure what to do now. My PHP5 scripts are running...
2
by: parez | last post by:
Hi All! This is the first time i am tryin to write a sql server 2000 function. I need to clean up some of my stored procedures.. Can any one please give me skeleton for a userdefined function...
11
by: Sweety | last post by:
hello to all members, i have strange question in C. main() { printf("%d",main) ; } here o/p is same for all m/c in TC++ version 3.0 i.e 657. I think this is not garbage.
2
by: Mike | last post by:
Hello, Im doing this in php5, apache Im not sure where the problem lies but I have a file <?php Class CreateXML{ public function xmlDeclaration(){ return $varxmlDec = "<?xml version='1.0'> ";...
5
by: Aziz | last post by:
Hi, I've recently contacted technical service of a web hosting company and asked them wheter or not they're gonna upgrade to PHP5 and MySQL5. Here's a quote from their response which confused me...
0
by: cty | last post by:
Title: Problem in session using php5 Good day, I use php5+mySQL4+IIS5.x Previuosly i use php4 and no error occur,
19
by: McKirahan | last post by:
I am working in two environments neither configuration of which I can change; one's my Web host the other a client. My Web host requires the use of the ".php5" extension to use PHP v5.1.4; where...
6
by: newlearner | last post by:
Hi, i know we can wirte a userdefined callback function.. I had a try for a long time though i feel im near but not able to coin out the exact thing. can any body tell me about a user defined...
3
by: Alamin Ahmed | last post by:
what is the best way to store and call php classes written and submitted by other developers? let's say i want to do the following $obj = new $userclass(); $obj->display($assoc_array); ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.