2014-01-20 51 views
2
Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace: 
#0 C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php(138): session_write_close() 
#1 [internal function]: CHttpSession->close() 
#2 {main} Next exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace: 
#0 C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php(0): session_write_close() 
#1 [internal function]: CHttpSession->close() 
#2 {main} Next exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace: 
#0 C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php(0): session_write_close() 
#1 [internal function]: CHttpSession->close() 
#2 {ma in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php on line 138 

如何解決這個問題,我無法找到任何答案致命錯誤:未捕獲的異常「異常」有消息「的

+0

你想在會話中存儲SimpleXml對象嗎? – Fracsi

+0

你的代碼是什麼?哪裏得到這個錯誤? –

+0

@fracsi是的,我在會話中存儲simplexml對象 –

回答

0

我有同樣的錯誤序列化。我使用會話數組糾正了它

+0

你能說明一下嗎? –

0
foreach ($output['tab_displayId'] as $id_display => $id_param){ 
       $test = new ClParaWidget($id_param, $id_display); 
       $output[$id_display] = $test->toString($id_display); 
       if (Yii::app()->session['S' . $id_display] != $output[$id_display]) 
        Yii::app()->session['S' . $id_display] = $output[$id_display]; 
      } 
0

我給出了更多解釋。如果我想在一個會話值保存數組:

Yii::app()->session['data'] = $array_data; 

有時,該代碼將返回錯誤:

Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace: 

爲此,我建議使用會話的陣列喜歡這裏:

foreach ($array_data as $id => $data)  
    Yii::app()->session['S_' . $id] = $data; 
相關問題