I'm currently working on a project that saves a login session in cookies, but currently I have a problem sharing the cookies beetween browser and a WebView.
I start the user interaction with the user reading a QrCode with the camera, but if the user wants to login I send a text message with the login session, but I can't find the cookies that I stored previously.
As far as I know thats because when I store cookies in the first session it stores in a WebView in the camera app and when I open a link inside the message app it opens another WebView and the cookies are not shared.
Is there a way to preserve the cookies beetween web sessions?
Edit:
Here is some code that I used to store the cookies and cache.
Cookie:
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
Cache:
async function saveCache(token) {
try {
let authCache = await caches.open('auth');
const responseBody = JSON.stringify({
token
});
const response = new Response(responseBody);
await authCache.put('/auth', response);
} catch (error) {
console.log("saveCache error:", { error });
}
}