I have a login script, and now I am trying to build a logout for it. I am using both cookies and sessions within CodeIgniter, and despite doing the below, the cookies still manage to stick and I can't figure out why. Allegedly this is the way to kill cookies via CI but I logout, close the page, go to another page and print_r($_COOKIE)
and they will still be there.
$this->session->sess_destroy();
delete_cookie('LongRemember', '', '0');
delete_cookie('AutoRemember', '', '0');
redirect('m/logout', 'refresh');
echo 'logged out';
Using the cookie helper you can delete a cookie in two ways:
delete_cookie("name");
delete_cookie($name, $domain, $path, $prefix);
This function doesn't not accept expiry parameters.
Don't forget to load the helper: $this->load->helper('cookie');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With