[eluser]jmb727[/eluser]
Is there a way to convert the session data saved by CodeIgniter in a cookie (ci_session) to an array? I've written the following function to achieve this aim but I wondered if there was a function built into CodeIgniter that did the same thing.
Code:
public function extract_session_variables()
{
$session_cookie = $this->input->cookie('ci_session');
if ($session_cookie == FALSE) {
return FALSE;
}
$session_cookie = $this->encrypt->decode($session_cookie);
$x01 = explode("{", $session_cookie);
$x02 = explode("}", $x01[1]);
$x03 = array_reverse(preg_split('/(s:[0-9]+:)|(i:)/', $x02[0]));
array_pop($x03);
$x03 = array_reverse($x03);
$cookieData = array();
foreach ($x03 as $k => $v)
{
if ($k % 2 == 0) {
$name = preg_replace('/[";]/', '', $v);
$value = preg_replace('/[";]/', '', $x03[$k+1]);
$cookieData[$name] = $value;
}
}
if (empty($cookieData)) {
return FALSE;
}
return $cookieData;
}