Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I noticed the same issue in one of my applications too. Debugging the problem lead me to discover that CodeIgniter is (was) not properly implementing serialization/unserialization of multi-dimensional arrays. There was actually a bug submitted for that, and I believe they either fixed it or about to fix it. Take a look at the their session lib in Core. </p> <pre><code>function _serialize($data) { if (is_array($data)) { foreach ($data as $key =&gt; $val) { if (is_string($val)) { $data[$key] = str_replace('\\', '{{slash}}', $val); } } } else { if (is_string($data)) { $data = str_replace('\\', '{{slash}}', $data); } } return serialize($data); } </code></pre> <p>Notice that it only goes through 1 level of your array and that the ONLY level that gets the slashes replaced. The problem is that you have multi-dimensional array and there's probably data there that's throwing off serialization and wiping your session. We fixed it by extending their session library and creating these calls:</p> <pre><code>class MY_Session extends CI_Session { public function __construct() { parent::__construct(); } function _serialize($data) { $data = $this-&gt;_serialize_backslash_recursive($data); return serialize($data); } function _unserialize($data) { $data = @unserialize(strip_slashes($data)); return $this-&gt;_unserialize_backslash_recursive($data); } function _serialize_backslash_recursive($data) { if (is_array($data)) { return array_map(array($this,'_serialize_backslash_recursive'), $data); } else { if (is_string($data)) { return str_replace('\\', '{{slash}}', $data); } } return $data; } function _unserialize_backslash_recursive($data) { if (is_array($data)) { return array_map(array($this,'_unserialize_backslash_recursive'), $data); } else { if (is_string($data)) { return str_replace('{{slash}}', '\\', $data); } } return $data; } } </code></pre> <p>This will now go through all the levels properly. Give it a try and see if it works for you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload