-
Hi I'm trying to read a cookie set by another web application, export const authCookie = createCookie("auth", {
maxAge: 60 * 60 * 1000,
});
export const loader = async ({ request }) => {
const header = await request.headers.get("Cookie");
console.log(header) // print auth=hello
const auth = await authCookie.parse(header);
console.log(auth) // print {}
...
}; The first console log prints |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The Remix cookie functions are designed to encode/decode cookies created by Remix, not generic cookies. These cookies are typically base-64 encoded and signed, so if not in the expected format, Remix will return an empty object. If you want to support 3rd party cookies, then you'll need to parse them yourself. You can use the Here's more discussion about it. |
Beta Was this translation helpful? Give feedback.
The Remix cookie functions are designed to encode/decode cookies created by Remix, not generic cookies. These cookies are typically base-64 encoded and signed, so if not in the expected format, Remix will return an empty object.
If you want to support 3rd party cookies, then you'll need to parse them yourself. You can use the
cookie
package, which is the same library that Remix uses.Here's more discussion about it.
#5198