• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI4 Session returns null

#1
using CodeIgniter [i]version 4[/i] and trying to set a variable in session like

LoginController


Code:
$session = \Config\Services::session();
$session->set(['user_logged_in' => true]);

and redirecting the user to another page



Code:
return redirect()->to(base_url() . '/user');

but when tried to get the value of  `
user_logged_in`  it returns `null`

UserController

Code:
$session = \Config\Services::session();
$session->get('user_logged_in');

Tried using the native PHP methods, but still the session variable is getting null. Tried to start the session in constructor but it results in error


Quote:ini_set(): A session is active. You cannot change the session module's ini settings at this time


What would be the problem? Please help.
Thanks.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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