2012年2月23日木曜日

CodeIgniter Sessionのエラー

CodeIgniterのSessionを使っていておかしいときがちょくちょくあった。(おもにver 1.7)
どうもSessionのデータがちょいちょい壊れる。

いい解決法を発見。
json_decode, json_encodeを使えることが前提

https://github.com/EllisLab/CodeIgniter/issues/13


Session.phpの_serializeと_unserializeを書き換える。


function _unserialize($data)
{
    return json_decode($data, true);
}

function _serialize($data)
{
    return json_encode($data);
}

Good!!!