Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies: can't read for SPA #17804

Closed
drev74 opened this issue Jan 31, 2025 · 3 comments
Closed

Cookies: can't read for SPA #17804

drev74 opened this issue Jan 31, 2025 · 3 comments

Comments

@drev74
Copy link

drev74 commented Jan 31, 2025

What happened?

Hello ! I'm trying to access a cookie from the SPA mode without a success 🙄 .

I followed your docs and have the following code:

const $q = useQuasar()

const allCookies = $q.cookies.getAll()
const cookie = $q.cookies.get(sessionCookie)

console.log(`*** session cookie is set: ${JSON.stringify(allCookies)}`)
console.log(`*** cookie: ${cookie}`)

Is there anything I'm doing wrong with this ? 🤔

Quasar -

Image

What did you expect to happen?

Cookies can be accessed

Reproduction URL

http://0.0.0.0:9000

How to reproduce?

  1. Setup a basic SPA app
  2. Set Cookies with the backend
  3. Try to access cookies from a Vue component

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite), Components (quasar)

Platforms/Browsers

Chrome

Quasar info output

Operating System        Linux(6.8.0-52-generic) - linux/x64
NodeJs                  22.9.0

Global packages    
  NPM                   11.0.0
  yarn                  Not installed
  pnpm                  9.15.4
  bun                   Not installed
  @quasar/cli           2.4.1
  @quasar/icongenie     Not installed
  cordova               Not installed

Networking         
  Host                  lap
  wlp0s20f3             192.168.0.12
  br-770db3a45ab6       172.18.0.1

Relevant log output

Additional context

No response

Copy link

Hi @drev74! 👋

It looks like you provided an invalid or unsupported reproduction URL.
Do not use any service other than Codepen, jsFiddle, StackBlitz, CodeSandbox, and GitHub.
Make sure the URL you provided is correct and reachable. You can test it by visiting it in a private tab, another device, etc.
Please edit your original post above and provide a valid reproduction URL as explained.

Without a proper reproduction, your issue will have to get closed.

Thank you for your collaboration. 👏

@drev74
Copy link
Author

drev74 commented Feb 1, 2025

UPD: I'm able to use quasar cookies API to set/get my own cookie. But I can't access httpOnly and sameSite=Lax cookies, set by my backend.

Pls see below

Image

@yusufkandemir
Copy link
Member

The sole reason why HttpOnly exists is to prevent JS from accessing it. So, that's the expected browser behavior. It's impossible to achieve it.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#httponly

@yusufkandemir yusufkandemir closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants