Auto delete in database when cookie expires

Asked

Viewed 27 times

0

Hello, I have a question, on my site I have a login system that when the data is validated, the system generates a hash that stores a cookie in the browser, and saves in the database an association of this hash with the user profile id! But I wanted that when the cookie disappeared from the browser automatically be deleted from the database that association, for security reasons! Does anyone know how to do it?

  • You can always check if there is a record of the user’s hash in the database. If there is a BD entry and there is no cookie, then delete the BD hash.

  • You could also save the expiration date of the cookie in the database. Hence, any user logging in, verify that this date is less than the current date and delete all records where this date is less than the current date.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.