I am trying to implement a demo account in one of my php webapps.
The concept is, that the user would have a total of x hours (max) access to the application since his first login. I am thinking of a frontend counter (javascript) that would begin from the first login and if the user quits the browser it will update the remaining hours on the database (before closing).
I wonder if there is a better way to do this. Any ideas?
It depends on how much is it important for you to stop potential misuse.
This way I could create the demo account and, before exiting your page, turn off js, so update never happens and I have my everlasting demo account 🙂
I would go with updating the time on every page and checking if number of free hours is used.