Welcome Guest, Not a member yet? Register   Sign In
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




Theme © iAndrew 2016 - Forum software by © MyBB