manas
manas

Reputation: 6400

How does the cookie-session middleware work in expressjs?

I want to know the underlying concepts of cookie-session in expressjs. When ever we stores something in session for example

req.session.myName = "Manas Tunga";

where this session data is stored ?? is it in client side session cookies or in server memory. And how does the cookie-session middleware work without having the cookie-parser middleware. How does the session cookie parsed without cookie-parser middleware ??

Does cookie-session creates a in memory session object ?? or it stores every session data only in client side session cookie. or it uses both . I am bit confused.

Upvotes: 2

Views: 2054

Answers (1)

micnic
micnic

Reputation: 11245

where this session data is stored ?

The data is stored in the client's cookies

How does the session cookie parsed without cookie-parser middleware ?

The cookie-session module has as dependency the cookies module which allows for getting and setting HTTP cookies

Does cookie-session creates a in memory session object ?? or it stores every session data only in client side session cookie. or it uses both.

It creates a session object which is stringified and encoded in base64 and finally stored in client side session cookie

Upvotes: 3

Related Questions