Welcome Guest, Not a member yet? Register   Sign In
Problem trying to store cookie in Codeigniter 4

I have been trying to make use of cookie in my Codeingiter 4 Project. 

But when i set cookie cookie it set because i var dump it after setting it buh affter i set it and it remove the setting command and try to get the recently get cookie it return null.

How can we hold cookie in codeigniter 4?

PHP Code:
$cookie = [
            'name' => 'testes_cook',
            'value' => 'Hello world',
            'expire' => '86500'
            echo 'already has one';

Cookies do not update until there is a page refresh.

Refresh your page and see if it is there.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

I comment out set cookie and refresh my page is return null the cookie is gone instantly

(This post was last modified: 04-14-2020, 01:22 PM by Leo.)

Your expire is too short. Its gotta be expire in the future. Basically time() + 86500;
It's probably too late, and you figured it out but, maybe someone else stumbles in this problem, besides you...or me.
ex: setcookie('testes_cook', 'Cooking testes??', time() + 86500, '/', '', $secure); //$secure - true if https, false if http
You can see things I made with codeigniter here: itart.pro its not overly impressive as I have very little time to learn.

Not too late I still can figure the issue bout till now thank I will try that.

Theme © iAndrew 2016 - Forum software by © MyBB