• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


27 Apr, 2025

Updated at 18 May, 2025

Best practice for creating and verifying guest accounts (localStorage or cookies)

First, I'll say I've read several articles about the dangers of storing things in localStorage and cookies are recommended in many cases. However, cookies seems insufficient for creating a guest account because of browser privacy settings. Especially because of Safari. In their settings, the only setting that mentions "cookies" is to block all cookies (first and third party). So a regular user who values privacy and doesn't know any better could have that checked. Now in my app, I was previously creating a guest user by signing a JWT with the unique userName and using that determine who the user was, and what database record I need to modify. However if a user is blocking cookies, this wont work. I want everyone to be able to create a guest account with no friction. So then I was considering using localStorage still with a signed JWT. Since it's signed with a secret, it should be secure. But the problem is, I'm not able to use middleware to set the user context with the guest user's info.

So...what is the best practice for creating guest accounts?