When assigning a type casted array to codeigniter's session, I get this error:
A PHP Error was encountered
Severity: Warning
Message: htmlspecialchars() expects parameter 1 to be string, object given
Filename: libraries/Profiler.php
Line Number: 514
Code in question:
$guest = array('email' => 'empty', 'username' => 'Guest');
$this->session->set_userdata(array('current_user' => (object)$guest));
The CodeIgniter profiler breaks as soon as you store any non-array non-strings in its session:
foreach ($this->CI->session->all_userdata() as $key => $val)
{
if (is_array($val))
{
$val = print_r($val, TRUE);
}
$output .= "<...>".htmlspecialchars($val)."<...>
";
}
(from CI_Profiler::_compile_session_data()
)
This looks like a pretty stupid thing since print_r()
works fine with objects - so is_array($val) || is_object($val)
would be more appropriate.