User JWT sent to the browser as an HTTP-only cookie. My question is, what is the best way to communicate the display name and user database ID, etc. to the browser?
I know that information can and does be set in the JWT payload, but isn't it best practice to make that cookie (JWT) unavailable to client-side JavaScript?
I can think of two ways - setting custom response headers, or sending the data as JSON in a element. The idea is to send it out of band, so to speak.
I want to stay compliant.
I think the correct answer is to set the no-cache response header and then store the returned information in localStorage, but wanted to ask...
Multiple cookies can be sent to the browser, and they can optionally be marked as HTTP Only, as shown below. Additionally, your server can send data/JSON in response to your browser XHR/Fetch requests.
result: