Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Where to save session id generated from the backend?

I’m developing an website and I need help to understand how to manage session ids.
My session ids are generated from my backend (firebase).
These session ids are put inside the header of every http request that’s coming from the frontend.

Now my question: where do I save them?

I cannot use cookies because I want that even the users that do not want cookies can use my website.
Any help would be appreciated.
Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

First of all, you can build a context which can save a session id and return at any time.

And after that, you can save a session id to local storage.

https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem

localStorage.setItem('sessionId', sessionId);

And then you can use the session by using localStorage.getItem like below.

const sessionId = window.localStorage.getItem('sessionId');

https://developer.mozilla.org/en-US/docs/Web/API/Storage/getItem

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading