[eluser]ThatsJustMe[/eluser]
Hello,
What would be the best choice of making sessions after I have validated login data? Well basically, I need to set people as online, after he has passed the login validation, and so he doesn't need to relogin after moving to another page or reloading page. In normal php I do it with sessions, but in codeigniter sessions are stored in database so I'm a little bit confused.
this is my current script, please suggest what I should update -
Code:
public function logout() {
$this->load->helper(array('form', 'url'));
$this->session->unset_userdata('logged_in');
$this->session->unset_userdata('username');
$this->session->unset_userdata('ip_address');
$this->session->sess_destroy();
redirect('/home', 'refresh');
}
// Do validation after registrate button is pressed.
public function validate() {
validation stuff goes here....
// If doesn't pass validation, redirect's back with errors.
if ($this->form_validation->run() == FALSE)
{
$this->load->helper('url');
$this->load->view('includes/header');
$this->load->view('login');
$this->load->view('includes/footer');
}
// If everything is correct logins.
else
{
$login = array(
'ip_address' => $this->input->ip_address(),
'username' => $this->input->post('uname'),
'logged_in' => TRUE
);
$this->session->set_userdata($login);
redirect('/profile','refresh');
}
}
Well basically currently it sets sessions, but it deosn't logout. Could you give me some hints, what I'm doing wrong?