Session data lost after route redirect |
-
lelolenda Newbie

-
Posts: 7
Threads: 5
Joined: Jul 2021
Reputation:
0
(12-20-2024, 11:04 AM)captain-sensible Wrote: the only session stuff i care or bother with is when admin gui is accessed and admin logs in, or somebody attempts to log in . I have a few methods in a class and several views. I just put this line at the top of every method in the class
Code: $session = \Config\Services::session();
eg
Code: public function displaySession()
{
$session = \Config\Services::session();
if( isset($_SESSION['role']))
{
echo " S_session[role] is :".$_SESSION['role'];
}
else
{
echo "session role not set";
}
}
session info doesn't seem to get lost, even when a view displays form , data is collected from submission etc , picked up by another method its still there .The only thing that clears data is a URL logout ,which is picked up via routes .code is :
Code: public function logout()
{
$session = \Config\Services::session();
unset($_SESSION['role']);
unset($_SESSION['count']);
$data= [
'title'=> 'logout',
'info'=> 'you may have already been logged out, but if you were not you are now !' ,
'date'=>$this->myDate
];
echo view('info', $data);
thank you
|
Messages In This Thread |
RE: Session data lost after route redirect - by lelolenda - 12-20-2024, 01:40 PM
|