php - User still online after closing page -


i'm working php login script. (and have stupid beginner question) plan log off users cookie after 1 hour.

but if user didn't press logout button user stayed online (on database table there keeps record open on mysql db) when deleted record goes fine , user can login.

could me out? need let script delete session or else?

solution: problem needed delete (make sure) user login data deleted before users wants login again. made small script deletes open session user if want login. after stopped using own code. using codeigniter , works good!

indeed, that's way sessions typically work. once page loaded, there's no connection between browser , server anymore. basically, once page has finished loading , sitting there in browser, it's same if user had closed window.

there's no way 100% reliably detect whether user still "online" or not. you'd have have javascript send constant heartbeat that, comes down timeouts. if have not seen user amount of time, assume offline , delete session. that's can do.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -