Welcome Guest, Not a member yet? Register   Sign In
redirect() function clears out any set_cookie
#1

(This post was last modified: 06-14-2020, 01:19 AM by burgoyn1.)

If you set a cookie, then redirect to another page, the cookie does not get set. This used to work in codeigniter 3.

PHP Code:
helper'cookie' );
set_cookie'my_new_cookie''this is some cookie text'60 60 24 );

$redirect redirect();
$redirect->to'/cookie_check' );
return 
$redirect

If you set the cookie without the redirect, it works.

PHP Code:
helper'cookie' );
set_cookie'my_new_cookie''this is some cookie text'60 60 24 ); 

Also, if you use the built in php setcookie function, it works as expected

PHP Code:
setcookie'my_new_cookie''this is some cookie text'time() + 60 60 24 7'/');

$redirect redirect();
$redirect->to'/cookie_check' );
return 
$redirect
Reply




Theme © iAndrew 2016 - Forum software by © MyBB