ktosiek / streamlit-cookies-manager

Access and change cookies from your Streamlit script
41 stars 29 forks source link

Please add samesite and secure to cookie, Otherwise it's not working in mobile browser #12

Open eli103 opened 4 weeks ago

eli103 commented 4 weeks ago

FYI.

Please add SameSite and Secure to cookie, Otherwise it's not working in mobile browser

function saveCookies(queue: { [k in string]: CookieSpec }) {
    Object.keys(queue).forEach((name) => {
        const spec = queue[name]
        if (spec.value === null)
            targetDocument.cookie = `${encodeURIComponent(name)}=; max-age=0; path=${encodeURIComponent(spec.path)}`
        else {
            const date = new Date(spec.expires_at)
            targetDocument.cookie = (
                `${encodeURIComponent(name)}=${encodeURIComponent(spec.value)};` +
                ` expires=${date.toUTCString()};` +
                ` path=${encodeURIComponent(spec.path)};`
            )
        }
    })
}