简体   繁体   中英

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';

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM