A question about cookies
mattsrobot opened this issue · 1 comments
mattsrobot commented
Describe the bug
Not sure if this is a bug or just something I don’t understand yet with Electron.
I have a remix app running almost perfectly within electron (thankyou).
however, session storage doesn’t appear to be functional.
Have you tried using a cookie session storage in a remix server file and setting some cookie value within a remix action?
Minimal Reproduction
Beep
Steps to Reproduce the Bug or Issue
try login
Expected behavior
Should login
Screenshots or Videos
No response
Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
No response
mattsrobot commented
Ok I was able to get this to work, the trick is to use Electron cookie manager, not remixes:
let theme = null;
if (!!process.env.ELECTRON) {
const session = electron.session.fromPartition('persist:wikid');
theme = await session.cookies.get({name: THEME_SESSION_KEY});
theme = theme?.at(0)?.value;
} else {
const cookie = request.headers.get("Cookie");
const session = await sessionStorage.getSession(cookie);
theme = session.get(THEME_SESSION_KEY);
}