CodeIgniter Forums
Session on ajax - 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: Session on ajax (/showthread.php?tid=84940)



Session on ajax - pippuccio76 - 11-24-2022

hi , i create a project where a type of user   send data to db only in ajax (dataentry) . How can i manage session with Ajax to redirect if the session expired ? Can i set session that expire  only on browser exit ?


RE: Session on ajax - InsiteFX - 11-25-2022

Check whether a PHP session exists or expired using AJAX


RE: Session on ajax - pippuccio76 - 11-26-2022

Thank's for reply.there Is a way tò destroy session only when closing the browser?


RE: Session on ajax - InsiteFX - 11-27-2022

Right, but that is only on the web browser closing.


RE: Session on ajax - pippuccio76 - 11-27-2022

(11-27-2022, 12:38 AM)InsiteFX Wrote: Right, but that is only on the web browser closing.

How can i do on web browser closing?
Is an intranet web app , i want only have session set .


RE: Session on ajax - InsiteFX - 11-27-2022

You can try playing around with this may get you start on building something that works.

User Login Session Timeout Logout in PHP


RE: Session on ajax - pippuccio76 - 11-27-2022

(11-27-2022, 09:50 AM)InsiteFX Wrote: You can try playing around with this may get you start on building something that works.

User Login Session Timeout Logout in PHP

I have several project that work fine with ci4 , but everyone have normal session  .This project , user side, work only on ajax and i must only destroy session on browser close 


For ci4 and .env file how can i set session to expire on browser closing :

app.sessionExpiration = ?


RE: Session on ajax - kenjis - 11-27-2022

(11-27-2022, 10:00 AM)pippuccio76 Wrote: For ci4 and .env file how can i set session to expire on browser closing :

app.sessionExpiration = ?

See https://codeigniter4.github.io/CodeIgniter4/libraries/sessions.html#session-preferences