Welcome Guest, Not a member yet? Register   Sign In
Can't use cookie helper in CI 4.0.4
#1

(This post was last modified: 07-18-2020, 02:28 AM by jreklund.)

I can't use from helper cookie CI4:

Code:
delete_cookie();
get_cookie();
set_cookie()

But I can using $_COOKIE, from CI 4.0.3.

Code:
setcookie();

However, I can only setCookie and not change it from CI 4.0.4.
Reply
#2

Did you load the cookie helper in the BaseController ?

I just tested the cookies and they work fine CI 4.0.4
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(07-18-2020, 03:45 AM)InsiteFX Wrote: Did you load the cookie helper in the BaseController ?

I just tested the cookies and they work fine CI 4.0.4
I have loaded it. I can create a cookie, added new cookie. But I can't change or reset it.
Reply
#4

It works I just did it, When you first write a cookie the web page needs to be refreshed
to update the cookie:

PHP Code:
// To delete cookie
        //set_cookie('test', '', time()-3600);

        // Create first cookie
        //$data = 'TEST';

        //set_cookie('test', $data, time()+3600);

        //echo get_cookie('test');

        // Create second cookie NOTE you need to click refresh in your browser to see it.
        
$data 'TEST2';

        
set_cookie('test'$datatime()+3600);

        echo 
get_cookie('test'); 

Those are the test steps I took when I create the updated second cookie I had to refresh my
web browser for it to show the updated cookie value.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 07-20-2020, 03:05 PM by Didytz.)

Hi,
I have same problem.

I have included helper("cookie") but it is not setting nor deleting cookie.

But If I use standard PHP  "setcookie...." it works fine. So basically I have same problem as OP.

UPS, my bad. I am still using 4.0.3 and it seems that i need 4.0.4 for set_cookie...
Reply
#6

When working with cookies you need to do a web browser refresh to see the cookie update.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(07-21-2020, 03:22 AM)InsiteFX Wrote: When working with cookies you need to do a web browser refresh to see the cookie update.

I know that and I do refresh but it seems that something is not working with cookie helper as I am.abel.to set cookie directly with php setcookie(....) And it is working that way.
Reply
#8

What I posted above works here using the CodeIgniter developer version.

This is a Windows 10 Pro x64 system using XAMPP Cookies work fine here.

Check you app/Config/app.php file and check your cookie settings.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

Are you stopping execution of the script with a dd(), die(), etc? If so that would stop the cookies from being sent or updated.
Reply
#10

(07-23-2020, 07:00 AM)kilishan Wrote: Are you stopping execution of the script with a dd(), die(), etc? If so that would stop the cookies from being sent or updated.
No
Reply




Theme © iAndrew 2016 - Forum software by © MyBB