Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter can't delete cookies

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';
like image 368
chris Avatar asked Dec 20 '22 19:12

chris


1 Answers

Using the cookie helper you can delete a cookie in two ways:

  1. delete_cookie("name");
  2. 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');

like image 180
Yan Berk Avatar answered Jan 02 '23 08:01

Yan Berk