I have a web application and I keep a list of logged in users in the mysql database.
If a user clicks the sign out button his details are subsequently deleted from the logged in users table and safely logged out. This works fine.
Now the problem is if a user fails to click the sign out button and clicks the close button on his browser then his details are left in the login table indicating he's logged in while he's not.
How do I go about this?
Thanks.

You will have to have a inactivity timeout. Probably around 20 to 30 minutes. Just have some code to check to make sure the user is still active otherwise delete them.

You can also implement a javascript solution. I have seen where you can use a function run onunload via ajax and delete the record. You would still need to have the timeout, since js can be disabled though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.