| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2010-06-11 23:35 UTC] nn at tronix dot pl
 Description:
------------
If server class is included / required (or included/required once) from external file the persistence doesn't work.
I think that the BUG is related to already reported bugs #51561 and #44267. 
Test script:
---------------
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) {
        echo "<PRE>";
        echo $sf;
  }
?>
server.php
--------------
<?php
  session_name('PSESSION');
  if ( $_COOKIE['PSESSION'] ) {
    session_id($_COOKIE['PSESSION']);
  }
  $res = session_start();
  require('class.bar.php');
  $server = new SoapServer(NULL, array('uri' => 'http://193.59.86.29/'));
  $server->setClass('Bar');
  $server->setPersistence(SOAP_PERSISTENCE_SESSION);
  $server->handle();
?>
class.bar.php
--------------
<?php
  class Bar  {
    public $var = 0;
    public function login() {
      return session_id();
    }
    public function incVar() {
      $this->var++;
      return $this->var;
    }
  }
?>
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: Tue Nov 04 15:00:01 2025 UTC | 
The line 14 in server.php should be changed to: $server = new SoapServer(NULL, array('uri' => 'http://localhost/')); ^^^^^^^^^^^^^^^^^^^^^^