CodeIgniter Forums
set_cookie does not work - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: set_cookie does not work (/showthread.php?tid=67397)



set_cookie does not work - SirTom - 02-17-2017

I try to set a cookie for remember_me:

PHP Code:
$this->load->helper('cookie');
...
set_cookie(array(
            'name'   => $name,
            'value'  => $user
            'expire' => $expire
        
));
... 

After the login I get only the Session.

http://prntscr.com/ea2ixb

Thanks for your help.
Tom


RE: set_cookie does not work - InsiteFX - 02-17-2017

Your setting the cookie wrong, should be set like below:

PHP Code:
setcookie($cookie_name$cookie_valuetime() + (86400 30), "/"); // 86400 = 1 day 



RE: set_cookie does not work - SirTom - 02-18-2017

(02-17-2017, 02:28 PM)InsiteFX Wrote: Your setting the cookie wrong, should be set like below:

PHP Code:
setcookie($cookie_name$cookie_valuetime() + (86400 30), "/"); // 86400 = 1 day 

Thank you for your answer!
But setcookie is a php function and set_cookie is a ci function. Is the usage still the same?


RE: set_cookie does not work - InsiteFX - 02-18-2017

Yes it is still the same, but you can use an array in $name. It is just an Alias for CI .system/core/Input.php (SEE: set_cookie)

Also see ./system/helpers/cookie_helper.php