Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

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

Problem

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?

Problem courtesy of: Randomblue

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...

Solution courtesy of: Nick Mitchinson

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

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

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×