Reputation: 99
How come destroy_session() method doesn't work.
After set_session(), destroy_session(), I still can read_session().
function set_session() {
$this->load->library('session');
$this->session->set_userdata('id', 4);
}
function destroy_session() {
session_start();
session_destroy();
unset($_SESSION);
session_regenerate_id(true);
}
function read_session() {
$this->load->library('session');
$id = $this->session->userdata('id');
echo $id;
}
Upvotes: 2
Views: 55460
Reputation: 1741
The Codeigniter session class does not utilize native PHP sessions. It generates its own session data, offering more flexibility for developers.
to unset a session variable:
$this->session->unset_userdata('variable');
to destroy the whole session:
$this->session->sess_destroy();
hope this helps. ref: codeigniter doc
Upvotes: 16