Cookies aren't being assigned to the client

const session = require('express-session');
const MongoDBSession = require('connect-mongodb-session')(session);
  app.post('/api/login',express.json(),async (req, res) => {
      const { username, password } = req.body;
      let user=await db.collection("users").findOne({name:username});
       let pw=await db.collection("users").findOne({password:password});
    if(user && pw){
      req.session.user = {  name: user.name,id:user.id };
      res.json({msg:'Login successful',name: user.name,id:user.id});
    }
    else{
      res.status(404).json({msg:"Invalid Name or Password"})
    }
  });
so my backend or api is deployed on heroku and I am trying to log in but the cookies are not assigned on the client , I do see the cookie id in my mongodb collections , what is wrong with my code ?
Please Help
Was this page helpful?