Problem to add passport authentation in MERN stack

I’m try to implement local authentication in reactjs using passportjs but I don’t understand some concept that I face during implement auth I have some questions.

1: How this session middleware works

   secret: "thisissecretcode",
   resave: true,
   saveUninitialized: true

2: What is the use of cookePraser middleware


3: what is credentials cors() middleware in server

credentials: true 

and withCredentials

withCredentials: true, 

and what is withCredentials in client side

The session middleware allows you to create sessions, which will store data per user visit. The session data is stored serverside and a session-id value is stored in a browswer cookie. The secret is what is used to sign the cookie. For a description of what the other options do, you can look them up in the documentation here Express Session Middleware.

The cookie-parser middleware will parse the cookie header from the request and make it available via req.cookies. As you’re using it will check for signed cookie values (looking for a values signed with thisissecretcode) and make those values available via req.signedCookies. For full details check the Cookie-Parser Middleware documentation.

The credentials: true option will ensure the Access-Control-Allow-Credentials header is sent with responses. That header works in conjunction with the withCredentials property of an XMLHttpRequest. You should read the details on the Access-Control-Allow-Credentials header to understand it.