0

How to store userid into headers ??

Creating a mern social media application. Want to send userid along with a post. How to store the userid ,so that it can be sent to server and linked together.

19th Jan 2022, 7:00 PM
Lakshay
Lakshay - avatar
1 Answer
0
I am assuming the "userid" is required to perform an operation on the user. You shouldn't store it in local storage. Instead set it from server as a HttpOnly and Secure cookie. This way, it will only be sent over HTTPS (ensuring it's encrypted) and saved inaccessible from JavaScript. Cookies are set in the header and are sent with each request.
24th Feb 2022, 8:59 AM
Mustafa A
Mustafa A - avatar