Welcome Guest, Not a member yet? Register   Sign In
Session lost after refresh page!
#1

Hi,
my problem with CI4 is that session not working after I refresh page.
I load session in BasicController but it nothing change.
Please help me.
Reply
#2

i don't think anybody can help with this since there is not enough information to go on.

Maybe you post your code your playing with in the controller , but as a starter ..in every controller
involved in a session , my approach is to put
session_start(); //at the start might not be the best approach but works for me




public function credentials()

{
session_start();
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply
#3

(07-01-2020, 08:48 AM)captain-sensible Wrote: i don't think anybody can help with this since there is not enough information to go on.

Maybe you post your code your playing with in the controller , but as a starter ..in every controller
involved in a session , my approach is to put
session_start(); //at the start might not be the best approach but works for me
 



public function credentials()

{
session_start();
I have same mistake.
In login Controller


Quote:$this->session->set($data['user']);
redirect()->to(site_url('/'));

But after redirect, session is null.
Thank you for your help!.

Reply
#4

In the 'receiving' controller, try inserting this somewhere at the top:
Code:
$this->session = \Config\Services::session();
Reply
#5

Or use the session helper it is changeable.

PHP Code:
$data = [
    'user' => 'Your not setting anything to it',
];

session()->set($data);
// or
$session = \Config\Services::session();
$session->set($data); 

Either way you are not assigning a value to $data['user']
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB