CodeIgniter Forums
Bug with sessions CI 4.5.1 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Bug with sessions CI 4.5.1 (/showthread.php?tid=90724)



Bug with sessions CI 4.5.1 - ALTITUDE_DEV - 04-23-2024

Hello CI Users, 

I'm encountering a rather strange bug with sessions in CODEIGNITER 4.5.1. Let me explain:
I log in to my dashboard, and the session is created without any issues.

- Scenario 1: If I close the browser tab and paste the URL of the admin panel, I'm still logged into my session.
- Scenario 2: If I close my browser and return to the panel via copy-paste, I'm still logged into my session.
- Scenario 3 If I close the browser tab and use the "search history," if I click on the panel in the search history, my session is destroyed, and I have to log in again, creating a new CI session.

Do you have any idea ? or its a bug ?


RE: Bug with sessions CI 4.5.1 - InsiteFX - 04-24-2024

Not sure how you are destroying your session, but try this.

PHP Code:
// remove takes eiter a single item or an array in $key
session()->remove($sessionData);

// destroy our session data.
session()->destroy();

// cleanup! 


Can you show your logout code?


RE: Bug with sessions CI 4.5.1 - ALTITUDE_DEV - 04-27-2024

Hello i have fix my problem with cookie type "Strict" > "Lax"

Is it possible to switch PHP session to database mode other than through cookie passing?


RE: Bug with sessions CI 4.5.1 - InsiteFX - 04-28-2024

Not that I know of off hand.


RE: Bug with sessions CI 4.5.1 - Bosborne - 04-29-2024

Have you checked the documentation?
https://www.codeigniter.com/user_guide/libraries/sessions.html

The defaults are to update every 5 minutes and automatically destroy the inactive session after 2 hours. You can use a database backend instead of files but that would not likely change the behavior. 

You can change some of the session defaults. One other option may be to use tempdata in your session.