Suppose a user is editing a record from a database, in the schema you have a field named 'lock' so users can not edit concurrently the same record, once the user ends editing you set lock = false to allow other users to edit the record.
My question is, can i run some code when php session ends, so if a user walks away from computer, close the browser or whatever, i can set the lock to false?. Because if not, and correct me if I'm wrong, the record would remain locked?
I've read the session_set_save_handler
section from php manual, but i'm not sure that
the 'close' callback it's what i need...
Or do I need to add a timestamp in the db schema and run a cronjob to 'unlock' the records every x time?
Thanks!