CodeIgniter Forums
Codeigniter 4 set_cookie Helper is not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Codeigniter 4 set_cookie Helper is not working (/showthread.php?tid=79468)



Codeigniter 4 set_cookie Helper is not working - zeeforum - 06-21-2021

I have found this problem while working with cookies. A little bit information how problem occurs, please read carefully.

I'm using cookie helper. When I tried to create cookie in controller method it's working fine (No Problem).
But When I generated my own helper their I tried to set cookie using cookie helper, it's not generating cookie in the browser.

That's the issue with Codeigniter 4 Cookie Helper/Library.


RE: Codeigniter 4 set_cookie Helper is not working - ikesela - 06-21-2021

(06-21-2021, 12:19 AM)zeeforum Wrote: I have found this problem while working with cookies. A little bit information how problem occurs, please read carefully.

I'm using cookie helper. When I tried to create cookie in controller method it's working fine (No Problem).
But When I generated my own helper their I tried to set cookie using cookie helper, it's not generating cookie in the browser.

That's the issue with Codeigniter 4 Cookie Helper/Library.

try check browser console for errors. modern browser require to set to true in config/App.php:
$cookieSecure = true;


RE: Codeigniter 4 set_cookie Helper is not working - InsiteFX - 06-21-2021

In your helper did you add these to the top of it just before the first function/method?
PHP Code:
use Config\App;
use 
codeigniter\Config\Services
Those are the only two things that would stop it from working.


RE: Codeigniter 4 set_cookie Helper is not working - zeeforum - 06-22-2021

Issue resolved, I have too redirect page withCookies.