简体   繁体   English

PHP标头删除cookie

[英]PHP Headers remove cookies

I've searched this question by google without success.. so I hope you can help me... I have two systems and I'm using a WS to connect then, I using PHP SOAP module. 我已经通过Google搜索了此问题,但没有成功..所以希望您能对我有所帮助...我有两个系统,我正在使用WS进行连接,然后使用PHP SOAP模块。

The issue is, my request return an error because I'm sending cookies. 问题是,我的请求正在发送错误,因为我正在发送Cookie。 (I don't set cookies in anywhere), but when I print the headers, there are cookies... (我不在任何地方设置cookie),但是当我打印标题时,有cookie。

How can I prevent that? 我该如何预防?

POST /XXXXXXXXXXXXXXX.asmx HTTP/1.1
Host: example.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.3
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.erp2iecs.com/webservices/IsCompleted"
Content-Length: 459
**Cookie: iECSAuth=;iECSAuth1=;**

Thanks! 谢谢!

public function connect()
    {
        global $db_process, $cfgGeneral;

        try
        {
            $this->client = new SoapClient($this->wsdl,array('trace' => 1));

            // Namespace of the webservice
            $ns = 'http://schemas.erp2iecs.com/webservices'; 
            // Soap header information
            $headerbody = array('User' => $cfgGeneral['user'],'Password' => $cfgGeneral['pass']);
            // Creates the header
            $header = new SOAPHeader($ns, 'Authentication', $headerbody);       
            // Set the Headers of Soap Client.
            $this->client->__setSoapHeaders($header); 
        }
        catch(SoapFault $fault)
        {
            // Could not connect
            $this->_error[] = '0003 - Error connecting to SOAP server. Error Message: ' . $fault;
            $this->report_email("ofiraee_webservice_error", implode(" || ",$this->_error), true);
            return false;
        }   
    }

public function send_request($function, $xml, $parameter_name)
    {
        try
        {
            // Invokes the method ServerBeginImport and passes the XML above
            $paramsBody = array(trim($parameter_name)=>trim($xml));

            $result = $this->client->$function($paramsBody);

            $result_function = $function . "Result";
            $guid = $result->$result_function;

            return $guid;
        }
        catch(SoapFault $fault)
        {
            // Something wrong happened with this!
            $this->_error[] = '0004 - [ '.$function.'(); ] [ ' . $this->wsdl . ' ] [ SOAP HEADERS ' . $this->client->__getLastRequestHeaders() . ' ] [ SOAP RESPONSE ' . $this->client->__getLastResponse() . ' ] [ SOAP REQUEST ' . $this->client->__getLastRequest() . ' ] Error sending request. Error Message: ' . var_export($paramsBody, true) . $fault;
            $this->report_email("ofiraee_webservice_error", implode(" || ",$this->_error), true);
            $this->save_request($guid, $xml);

            return false;       
        }
    }

I found a soluction! 我找到了解决方案! To clear all cookies present in soap client object you just need unset($soapClient->_cookies); 要清除soap客户端对象中存在的所有cookie,您只需取消设置($ soapClient-> _ cookies); all cookies are removed! 所有cookie被删除!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM