php - SimpleXMLElement' is not allowed in session_write_close() -
im not sure do. im trying make session string inside of function , parse session outside of , if makes sense.... im getting error "simplexmlelement' not allowed in session_write_close()" suggestions on can solve it?
function api_info($form, &$form_state){ $server_url = 'website api url' curl_setopt($ch, curlopt_url, $server_url ); curl_setopt($ch, curlopt_post, 0 ); curl_setopt($ch, curlopt_postfields, ); curl_setopt($ch, curlopt_httpheader, array("expect:") ); curl_setopt($ch, curlopt_failonerror, 1 ); curl_setopt($ch, curlopt_followlocation, ); curl_setopt($ch, curlopt_header, false ); curl_setopt($ch, curlopt_returntransfer, 1 ); curl_setopt($ch, curlopt_ssl_verifypeer, false ); curl_setopt($ch, curlopt_ssl_verifyhost, false ); curl_setopt($ch, curlopt_timeout, 120 ); curl_setopt($ch, curlinfo_header_out, true ); curl_setopt($ch, curlopt_http_version, curl_http_version_1_1 ); $xml_response_lead_point = curl_exec($ch); $xml_request_lead_point = new simplexmlelement($xml_response_lead_point); $result = reset($xml_request_lead_point->sm); $xml_request = $xml_request_lead_point; $xml_results = array( 'lead_response' => $result, 'results' => $xml_request, ); //dvm($xml_results['results']); //dvm($xml_request_lead_point); //dvm($a); $_session['lead_results'] = $xml_results['results']; return $xml_results; } $lead_results = $_session['lead_results']; var_dump($lead_results);
you need serialize()
simplexmlelement (or object) before stored in session , unserialize()
use.
$xml_obj = new simplexmlelement( $xml_string ); $_session['xml_value'] = serialize( $xml_obj ); $xml_obj2 = unserialize( $_session['xml_value'] );
alternatively save xml string used create object.
Comments
Post a Comment