问题
My program works properly.. it has several pages and if i click on the button of the browser to go back, it goes to the previous page:
BUT there is an error after loggin out. When i logged out the program redirects me to the login page, everything seems to be working fine but it does not
When i click on "logout" and the program redirects me to the login system IF I press the button in the browser to go back i got this error:
Do not know what is going on :/
Here is the program line error:
My code, the model file ("m_login"):
public function getDetails()
{
$st = $this->db->SELECT('cursadas.date as date, cursadas.grade as grade, usuarios.username as user, materias.name as subject')->from('cursadas')
->join('usuarios','usuarios.id=cursadas.user_id')
->join('materias','materias.id=cursadas.subject_id')
->WHERE('cursadas.user_id=',$this->session->userdata['id'])
->get()->result_array();
return $st;
}
My logout function:
public function logout(){
$this->session->sess_destroy();
redirect('login/index');
}
回答1:
Change getDetails() method by this
// $this->session->userdata['id'] to this code $this->session->userdata('id')
public function getDetails()
{
$st = $this->db->SELECT('cursadas.date as date, cursadas.grade as grade,
usuarios.username as user, materias.name as subject')->from('cursadas')
->join('usuarios','usuarios.id=cursadas.user_id')
->join('materias','materias.id=cursadas.subject_id')
->WHERE('cursadas.user_id=',$this->session->userdata('id'))
->get()->result_array();
return $st;
}
see the link for more info
https://www.codeigniter.com/user_guide/libraries/sessions.html#retrieving-session-data
来源:https://stackoverflow.com/questions/43312420/error-after-loggin-out