CodeIgniter Forums
Problem with delete session - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Problem with delete session (/showthread.php?tid=85123)



Problem with delete session - motoroller - 12-03-2022

i Have logout controller like this, my sessions stored in Redis

helper('cookie');

set_cookie([
'name' => 'country',
'value' => '',
'expire' => -25800,
]);

session()->destroy();

return redirect()->to('/')->withCookies();

After logout cookies are destroyed, but session still alive if I do next:

return redirect()->to('/');
session is destroyed, but cookies are still alive, how completle destroed cookies and session and one controller?


RE: Problem with delete session - cesartnic - 12-03-2022

Hi,
yo can try this:
first you need clear cache browser,
then use get cookie for verify if exist the cookie.


RE: Problem with delete session - InsiteFX - 12-05-2022

You can also try clearing out the data array.

PHP Code:
$data = [];

$session->set($data);

session()->destroy();