Problem with PHP5, CGI and Session
| From: | Markus Fischer | Date: | Wed, 15 Dec 2004 07:58:32 +0000 |
| Subject: | Problem with PHP5, CGI and Session | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-204388@lists.php.net to get a copy of this message | ||
Hi,
I'm expiriencing a problem when I use my application with PHP5 as a CGI module (this is due to my provider). I've developed and tested the application on two servers, both using PHP5 as module, without problems.
It seems that the session gets malformed somehow during the first reuqest.
1) On the first request, the session itself is empty:
array(0) { }
2) On the second request, using session cookies, I see the initialized session array:
array(1) { ["fru"]=> &array(1) { ["cache"]=> array(0) { } } }
But only as long as I'm in my applications constructor.
But as soon as my class' constructor returns, the session suddenly contains another value:
object(Application)#1 (4) {
["db:protected"]=>
object(TsMySQLConnection)#2 (4) {
["conRes:private"]=>
[......]
The simplified code-flow is:
session.php
class MySession {
function __construct() {
session_start();
$_SESSION['app']['cache'] = array();
}
}
application.php
class Application {
protected $session;
function __construct() {
$this->session = new MySession();
}
}
index.php
require_once 'application.php';
$app = new Application;
# here, var_dump($_SESSION['fru']) outputs suddenly the Application-class, instead of the empty array
$app->main();
I'm unable to find out the problem. It seems that after return from the constructor the _SESSION is messed up and contains the object which I just created newly.
Anyone expiriencing similiar problems?
regards,
- Markus