I have a site that stores registered user site settings in the MySQL database, and I hope to change this so that unregistered users can use browser cookies to benefit from the site settings.
Is there a general way to do this? My thoughts were to create an additional database table with these fields:
id unique_cookie_hash site_preferences
If a unique cookie is stored in a cookie, and the site’s settings are a JSON encoded string containing the settings of the guest user. Thus, for a user who is not registered on the site, the cookie will be checked. If a cookie exists, it will try to set the settings using the value stored in the cookie. If the cookie does not exist or no match is found, the site will create it and assign it default values.
When the guest makes a change, the site will attempt to launch an UPDATE request on its unique cookie_hash.
I suppose this will work (and that this is how most sites do it?), But since this is a newer concept for me, I was wondering if anyone knows of any good tutorials or "get-yas" to follow up with this method.
Thanks.
source share