• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
redirect() function clears out any set_cookie

#1
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.