Codeigniter错误数据中是否存在最大长度


Is there a maximum length in Codeigniter falshdata?

我之所以这么问,是因为我对一条想传递给下一个视图的愚蠢的小消息感到愤怒。所以如果我这样做:

if(!$this->paypal_pro->APICallSuccessful($PayPalResult['ACK']))
        {
            var_dump($PayPalResult['ERRORS']);
            $message=array();
            foreach ($PayPalResult['ERRORS'] as $row => $error){
                // $message['flashError'][$row]['L_SHORTMESSAGE'] = $error['L_SHORTMESSAGE'];
                $message['flashError'][$row]['test'] = "The Session class permits you maintain a user's";
                // $message['flashError'][$row]['L_ERRORCODE'] = $error['L_ERRORCODE'];
                // $message['flashError'][$row]['L_LONGMESSAGE'] = $error['L_LONGMESSAGE'];
            }
            // print_r($message);
            $this->session->set_flashdata($message);
            redirect('main/Form');
        }

它工作得很好,但如果我这样做:

    if(!$this->paypal_pro->APICallSuccessful($PayPalResult['ACK']))
    {
        var_dump($PayPalResult['ERRORS']);
        $message=array();
        foreach ($PayPalResult['ERRORS'] as $row => $error){
            // $message['flashError'][$row]['L_SHORTMESSAGE'] = $error['L_SHORTMESSAGE'];
            $message['flashError'][$row]['test'] = "The Session class permits you maintain a user's  and track their activity while";
            // $message['flashError'][$row]['L_ERRORCODE'] = $error['L_ERRORCODE'];
            // $message['flashError'][$row]['L_LONGMESSAGE'] = $error['L_LONGMESSAGE'];
        }
        // print_r($message);
        $this->session->set_flashdata($message);
        redirect('main/Form');
    }

它不起作用。

我在这里显示错误数据,以主/形式:

<?php if($this->session->flashdata('flashError')):?>
        <div class='flashError'>
    <?php   
        print_r($this->session->flashdata('flashError'));
    ?>
        </div>
    <?php endif?>

你可以猜到我正试图将Payal的错误消息拉到我的错误处理视图中。感谢

在Codeigniter中,整个会话数据的一般大小是有限的,是的。这也包括闪光信息。

这是因为默认情况下,它适用于cookie,并且cookie的大小有限。

防止这种情况的简单方法是使用基于数据库的会话或PHP本地会话适配器之一。

我在会话方面遇到了很多问题(除非存储在数据库中,否则默认情况下,会话在Codeigniter中基本上是cookie)。会话大小(或cookie大小)取决于浏览器,但我认为正常值约为3k,因此无法处理您的建议。

我不太确定是否要将会话详细信息存储在数据库中,所以添加了本机会话库,这变得容易多了(也减少了bug)。您仍然可以将CI flash数据功能与此库一起使用(以及设置会话数据,如$this->session->set_userdata('fo',$foo)),但它允许您像使用本机PHP一样使用会话,即您可以打印_r($_session)-我认为您无法使用CI中的默认会话功能。

这是一篇包含更多信息的帖子:CodeIgniter会话与PHP会话