I recently started a web application with react/typescript. In the authentication part, when a user registers or login I set cookies (using jsonwebtoken) to save the information. During testing when setting the cookies on the browser it works just fine on pc but not on IOS mobiles. I know that I can make it work by changing the browser settings, but it’s not really user friendly.
This is the code I used to set the cookies :
const payload = {
email: email,
id: result.insertedId
}
const token = jwt.sign(payload, process.env.TOKEN_SECRET as string,{ expiresIn: '30m' });
const refreshToken = jwt.sign(payload, process.env.REFRESH_TOKEN_SECRET as string,{ expiresIn: '30d' });
res.cookie("x-access-token", token, { httpOnly: true, secure: true, sameSite: "none", path: "/", maxAge: 30 * 60 * 1000 });
res.cookie("refreshToken", refreshToken, { httpOnly: true, secure: true, sameSite: "none", path: "/", maxAge: 30 * 24 * 60 * 60 * 1000 });
Is there a way to make it work on IOS mobiles (preferably without changing the browser settings) ?
Thanks in advance.
Chaussures is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.