Worth adding: the "memory only" approach (storing in a JS variable) has one practical use — short-lived access tokens in a refresh-token flow. You keep the refresh token in an httpOnly cookie, and the access token only in memory. On page refresh you silently re-issue the access token. This is the most secure pattern but adds complexity. For most apps, httpOnly cookies with a good session library (like NextAuth or Lucia Auth) is the right call.