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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.