Next.js Discord

Discord Forum

Access httponly cookies in client side

Unanswered
Araucanian herring posted this in #help-forum
Open in Discord
Araucanian herringOP
I would like to inquire about accessing httponly cookies in Next.js. I have tried using the Next Cookies library, but I am unable to retrieve httponly cookies on the client side. Can anyone suggest a solution or workaround for this issue?

2 Replies

as long as you use major web browsers such as Chrome, Safari and Edge, it is impossible.
If the HttpOnly flag is included in the HTTP response header, the cookie cannot be accessed through the client-side script. As a result, even if a cross-site scripting (XSS) flaw exists, and a user accidentally accesses a link that exploits the flaw, the browser will not reveal the cookie to the third-party.
https://www.cookiepro.com/knowledge/httponly-cookie/
Araucanian herringOP
@tafutada777 thanks