CodeIgniter Forums
Issue with cookie not setting - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Issue with cookie not setting (/thread-73584.html)



Issue with cookie not setting - scalla - 05-12-2019

Good day all, I followed the instruction in the documentation ot setting cookie, it does not work.

After checking through the cookie code, I discovered issue 1 that the sendcookie method is sent after the body is returned. Which makes the method inaccessible. 2 even when the sendcookie method is brought forward, and is accessible, the content of the 
Cookies array is empty.


RE: Issue with cookie not setting - kilishan - 05-12-2019

Providing example code is always good. Setting it on the response should be all that's needed:

Code:
$this->response->setCookie()



RE: Issue with cookie not setting - denis303 - 09-23-2019

CodeIgniter 4 rc.1 does not send cookies where controller response is redirect?

PS: Sorry, I do not have a full test, but I have a user authentication component where only native PHP method setcookie() is working.
https://github.com/denis303/codeigniter4-user-service/blob/master/UserService.php