I have a method which retrieve a session created before in a method. This method is called from AJAX and is something like:
public function Confirmar() {
print_r($this->session->userdata);
}
The session was created before from one method in the same controller which is:
public function Token($token) {
$params = array('tokenvalido' => true, 'token_de_cambio' => $token, 'user_mail' => $TokenValido->user_mail);
$this->session->set_userdata($params);
}
When i make a var_dump($this->session->userdata)
in the Token
method, I'm getting this response:
Array ( [__ci_last_regenerate] => 1522819707 [tokenvalido] => 1 [token_de_cambio] => 5ac44d3e7dc5cd0d11e2edbdb34ae13f05d60c3b64978 [user_mail] => babasonicofernando@gmail.com )
But when I called the Confirmar()
method (which exists in the same controller where I create the session) this is displaying an empty array.
What I'm doing wrong?
userdata
is method so you have to add ()
at end in . so change your code as below
public function Confirmar() {
print_r($this->session->userdata());
}
您可以尝试:
print_r($this->session->userdata('token_de_cambio'))
这段时间过后,我注意到在php.ini中启用了session.auto_start
指令,此问题已解决。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.