Welcome Guest, Not a member yet? Register   Sign In
NuSoap Lib and Session problems...
#1

[eluser]nevsie[/eluser]
Hey all... i have two wonderful working examples..
1 works to write a value to a session if it did not previously exist, if it did exist no change...
2 uses the nusoap lib to connect to a client and pull back information. Note currently i am also using simplexml lib to parse the XML to an array for ease of use...

Individually they work fine... together a number of problems arise...

The first and most common is that when putting them together the session appears to be created but not saved as it does not exist on page refresh.
Also, there appears to be issues with regards to the headers "Cannot modify header information".

I am certainly no pro at this and i am just plugging my way through as i would prefer to build this as part of a framework, rather than straight from PHP. Any help, advice, reasons would be appreciated... a sample of the code is below for reference... hope you can help!

Note in the example below that session is autoloaded and the nusoap part and session part are not even directly linked... although that is the intention, hopefully!!!

Code:
<?php

class Home extends Controller {

    function Home()
    {
        parent::Controller();
        $this->load->library("Nusoap");
        $this->load->library('simplexml');
    }
    
    function index()
    {
        $this->nusoap_client = new soapclient("http://mydomain.co.uk/WebServ.asmx?WSDL", true);
        $params = array('psXMLParams' => '&lt;?xml version="1.0" encoding="utf-8" ?&gt;<Connection><AName>Sample Name</AName></Connection>');
        $result = $this->nusoap_client->call('Connection', $params);
        $ConnectionResult = $this->simplexml->xml_parse($result["ConnectionResult"]);
        
        if ($this->session->userdata('spam') != FALSE)
        {
            echo "yup got me some userdata from session - ".$this->session->userdata('spam');
            echo "<pre>"; print_r($this->session->userdata); echo "</pre>";
        }
        else
        {
            $this->session->set_userdata(array('spam'=>'123456789'));
            echo "New ConnID - Should now be in session!";
            echo "<pre>"; print_r($this->session->userdata); echo "</pre>";
        }
    }

    function logout() {
        $this->session->set_userdata(array('spam'=>FALSE));
    }
}
?&gt;
#2

[eluser]nevsie[/eluser]
Just changing the message... the problem seems to only occur when you echo or print_r something from the controller before you use the set data in the session. Now i know your not supposed to do this... and i only normally do this for testing processes or when working something out, but this is a real pain!

Quote:A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/sites/mydomain.org/public_html/system/application/controllers/home.php:19)
Filename: libraries/Session.php
Line Number: 315




Theme © iAndrew 2016 - Forum software by © MyBB