php - delete_cookies() helper not working in codeigniter 4
Get the solution ↓↓↓I want to create a remember me feature on my website using cookie. when the user logout i want to destroy all session and cookies. But the problem is i can't delete existing cookie.
i'am using CodeIgniter 4 framework
i already loaded cookie helper in my BaseController. i tried this code in my logout controller :
delete_cookie('remember_me_token');
but that doesnt work, and also i tried this one :
set_cookie('remember_me_token', '', - 1209600); // set to minus
and the result is the same, i can't delete the cookie
please help :(
Answer
Solution:
I followed up with a different approach using the setCookie function which was chained using the response and simply set the expiry time to -1.
$this->response->setCookie(['name' => 'token','value' => "" ,'expire' => '-1','domain' => $domain, 'path' => '/'])
Reference : https://codeigniter4.github.io/userguide/outgoing/response.html?highlight=set%20cookie
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: gd library extension not available with this php installation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.