session not saved after running on the browser

457
July 28, 2022, at 10:30 PM

session not saved after running on the browser if we do that on the postman the session well be saved after login and logout but after i logedin in the browser and logout i"ll receive the default session not the session i"ll passed

userApi.js

router.post('/login', async function (request, response) {
console.log(request.body)
const user=request.body
let userFound=await User.find({$or:[{phoneNumber:user.emailPhoneNumber},
    {email: user.emailPhoneNumber,password:user.password}]}).exec();
if(userFound.length!=0){
    request.session.login=true
    request.session.save()
    response.send("success")
}
response.send("user not found")
});
router.get('/logout',async function (request, response){
console.log(request.session)
request.session.destroy()
})

connect to server

 logIn(user) {
    axios.post(`http://localhost:5500/login`,user);
}
  logout(){
 axios.get(`http://localhost:5500/logout`);
}

server.js

  app.use(
 session({
 secret: crypto.randomBytes(16).toString("hex"),
store: new MemoryStore(),
resave: false,
saveUninitialized: true,
cookie: {
  secure: false,
  maxAge: 24*60*60*1000}
})
);

login.js

const [userFound,setUserFound]=useState({});
const onFinish = async (values) => {
    console.log(values)
    let connectToServer=new ConnectToServer();
    connectToServer.logIn(values);
    let userFound1=await 
    connectToServer.getUserByEmailPhoneNumber(values.emailPhoneNumber)
    if(userFound1.length<1)
      {
        alert("user dosent found try again")
        return;
      }
    setUserFound(userFound1.data)
};

student.js the student have the logout button

const logoutfunc=()=>{
 let connect=new connectToServer();
 connect.logout();
 setclickLogout(true);
}
return (
 <div>
     <button onClick={()=>logoutfunc()}>logout</button>
     {clickLogout?<Redirect to={`/`}/>:null}
 </div>
)
Rent Charter Buses Company
READ ALSO
Best way to trigger worker_thread OOM exception in Node.js

Best way to trigger worker_thread OOM exception in Node.js

I would like to test code that reports when a worker_thread OOMsOr at least that the parent is OK despite the thread crashing due to OOM reasons

430
Firebase Cloud Functions: PubSub, &quot;res.on is not a function&quot;

Firebase Cloud Functions: PubSub, "res.on is not a function"

Im trying to use the etherscan API by using an axiospost() function

456
TypeError: Cannot read properties of undefined (reading &#39;createMessageComponentCollector&#39;)

TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')

Im trying to fix this error that I keep getting when I run /help, and don't know what I did wrong, I tried to do what I could with the error, but im getting annoyed at this point

569
AWS XRAY on Fargate service

AWS XRAY on Fargate service

I want to add xray to my Fargate serviceEverything works (synth/deploy) but in the logs I'am seeing the following error:

445