How to make cookies independent of device

Viewed 23

I am working on a Api with nodeJs and Mongodb alis Database for a next.js application. when a user login to the application a new access token is created and a new refresh token is created and stores on the cookies and it expriy after 3 day. i notice that when i login with my laptop, it automatical log me out of my mobile. and when i login to my mobile it automatical log me out on my laptop: here is my code below:

  const token = user.JWTAccessToken()
  const refreshToken = user.JWTRefreshToken()

    await client.set(user._id.toString(), (refreshToken));

    return res
    .status(StatusCodes.OK)
    .cookie("refreshToken", refreshToken, {
      sameSite: "none",
      httpOnly: true,
      maxAge: 1000 * 60 * 60 * 24 * 7,
      secure: process.env.NODE_ENV === "production",
    })
    .json({ token, refreshToken });

How do i write my logic to make refresh Token stores in the cookies independent of any devices

0 Answers
Related