|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-02-27 14:25 UTC] falk dot herrmann at bike24 dot net
Description:
------------
A soap server with SOAP_PERSISTENCE_SESSION is not persistence if the class Bar extends class Foo and the class Foo was included via include() or required().
If the class Foo is directly in the server code file (server.php), soap server works correct.
Reproduce code:
---------------
server.php
==========
<?php
session_name('PSESSION');
if ( $_COOKIE['PSESSION'] ) {
session_id($_COOKIE['PSESSION']);
}
$res = session_start();
require('Foo.php');
class Bar extends Foo {
public $var = 0;
public function login() {
return session_id();
}
public function incVar() {
$this->var++;
return $this->var;
}
}
$server = new SoapServer(NULL, array('uri' => 'http://localhost/'));
$server->setClass('Bar');
$server->setPersistence(SOAP_PERSISTENCE_SESSION);
$server->handle();
?>
client.php
==========
<?php
# Soap client
$client = new SoapClient(NULL,
array(
"location" => "http://localhost/server.php",
"uri" => "urn:xmethodsTest",
'trace' => 1
));
# SOAP requests
try {
$session = $client->login();
$client->__setCookie('PSESSION', $session);
print $client->incVar(); print "\n";
print $client->incVar(); print "\n";
print $client->incVar(); print "\n";
print $client->incVar(); print "\n";
print $client->incVar(); print "\n";
} catch (SoapFault $sf) {
# ...
}
?>
Foo.php
=======
<?php
class Foo {
}
?>
Expected result:
----------------
1
2
3
4
5
Actual result:
--------------
1
1
1
1
1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 14:00:01 2025 UTC |
circumvent the bug by starting the session after the class definition: server.php ========== <?php require('Foo.php'); session_name('PSESSION'); if ( $_COOKIE['PSESSION'] ) { session_id($_COOKIE['PSESSION']); } class Bar extends Foo{ public $var = 0; public function login() { return session_id(); } public function incVar() { $this->var++; return $this->var; } } $res = session_start(); $server = new SoapServer(NULL, array('uri' => 'http://localhost/')); $server->setClass('Bar'); $server->setPersistence(SOAP_PERSISTENCE_SESSION); $server->handle(); ?>