I have a user database that stores encrypted passwords, and would like to create a "Keep me logged in" cookie. I believe the following method should be secure enough for my purposes, but I would like to hear your thoughts:
- If the user selects the "Keep me logged in box" and provides proper credentials, create a cookie that contains a very large random string (call this the beacon). This is also stored in a separate column in the user table.
- Each time a user visits the page, search the user table for the beacon cookie. If it doesn't exist, do nothing. If it does exist, retrieve the user's information and treat them as logged in.
- When the user logs out, or logs in without the box checked, destroy the beacon cookie.
This could be manipulated if someone were to properly guess the beacon string, but my intent is to make it large and random enough that this is very difficult to do.