Search code examples
node.jseveryauth

Access server session information on the client without reload or extra request


I authenticate server-side with express.session. The normal way of communicating that session information client-side is to rerender the page with new HTML generated server-side, but this requires a reload.

I have a one page app and want to avoid reloading. Is there a way to access information about the connected user client-side? Is this information stored in a cookie? How can I access it without reloading the page or making an extra server request?


Solution

  • The only way to do this would be to either include the information in the initial server response (perhaps a dynamically generated JS object embedded in the HTML) or by making a second request as alessioalex suggested.

    It not possible to get information from the server WITHOUT talking to the server...