Jump to content

Execute on Session expirey


b1011

Recommended Posts

Hello.

My website uses sessions for the login functions and then they expire after a while so then it basically logs you out.

How can i get it so when they expire they execute some code, see i want to have an online users list and ill need to execute some mysql code when the session expires or they log-off.

is this possible? if not, are there any alternatives?

Link to comment
https://forums.phpfreaks.com/topic/60411-execute-on-session-expirey/
Share on other sites

You cannot execute time delayed PHP code if the page is already loaded.

 

You have to either

 

a) increase the session timeout

 

b) create a custom session management system (I do this through db)

 

c) You can keep every user logged in by making

AJAX call to a PHP file every 10 minutes or so that contains session_start(). This will refresh the session.

 

d) Force the users off of the page or let them know they are going to be logged out in x amount of minutes through javascript using setTimeout()

 

Personally the db sessions work the best for me.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.