I am sending a cookie from the server-side of my application. Cookie is visible in the response, it does not appear in the browser's cookie tab

22 views Asked by At

enter image description here

so here the response cookie is visible when i inspect in network fetch in devtool

but not in cookie tab enter image description here

and this is my server side code for sending cookies

function sendCookie(res, key, value, expDay) {
const exDate = new Date(Date.now() + expDay * 24 * 60 * 60 * 1000);

const cookieOptions = {
path: "/",
expires: exDate,
httpOnly: true,
};

res.cookie(key, value, cookieOptions);
}

module. Exports = { sendCookie };

// setting two cookies, the first one without option and second one with options

  sendCookie(res,"sessionToken", token, 365)

  return res.status(201).json({
    error: false,
    message: `Welcome Again ${userData.name}`,
    user: userData,
  });

// and this is my cors policy

app.use(
 cors({
  origin: "http://localhost:3000",
  methods: ["GET", "POST", "PUT", "DELETE"],
  credentials: true,
 })
 );

i don't know what i'm doing wrong

0

There are 0 answers