How can I use Astro.cookies in my Preact component?

88 Views Asked by At

I want to be able to use Astro.cookies in my Preact component, it was working before in dev testing but in production, it doesn't work

I tried to do import {AstroCookies} from "astro" and that seemed to work but it didn't after a while

Code I attempted to use to set the cookie:

const data = response.json()

const sessionId = data.sessionId
const maxAge = data.maxAge

try {
    Astro.cookies.set('sessionId', sessionId, {
        httpOnly: true,
        maxAge: maxAge
    })
} catch (e) {
   console.error(e)
}
0

There are 0 best solutions below