So this has been killing me for hours.
I have an ajax method that sets sessiondata when the user logs in. I’m sending a few vars via jQuery, and then outputting a message (could have just as well been “true”/”false”), which I am alerting out when it gets back to $.post.
Problem is this.. I am getting the “false” returned, although things seem to work. My session userdata does seem to be setting correctly. I built a button that alerts it out on the page and it is being set. I log out and confirm that all session data is cleared, and re-login and the session data sets correctly again. But the “false”/”PROBLEM WITH SESSION DATA” message is the one that is coming back to jQuery and being alerted every time.
public function setUserSessionData(){
$picture = $this->input->post('picture', TRUE);
$email = $this->input->post('email', TRUE);
$first_name = $this->input->post('first_name', TRUE);
$id = $this->input->post('id', TRUE);
ChromePhp::log($picture.$email.$first_name.$id); // all values good
$newData = array(
'loggedInStatus' => 'TRUE',
'picture' => $picture,
'first_name' => $first_name,
'id' => $id,
'email' => $email
);
// userdata is setting correctly
if($this->session->set_userdata($newData))
{
echo("Session data set");
}
else
{
echo("PROBLEM WITH SESSION DATA"); // this is the message that is outputting
}
}
Can anyone explain what is going on?
set_userdata()always returnsNULL.I don’t know where you go the idea that
set_userdata()should return anything. The documentation does not mention a return value and the code itself is documented as@return voidand does not contain areturnstatement.