Skip to content

Cookie path is not set to root #1

Open
@leandroprz

Description

@leandroprz

I was having issues with the cookie path and noticed that when clicking on Accept the cookie would be saved in the current path. So for example if I was browsing domain.com/blog/ the cookie would be saved for that path instead of /. Meaning everytime I visited another URL I got the popup again even though I already clicked on Accept.

I fixed it by adding path=/ to line 10 in app.js:

document.cookie = `${item}=${value};path=/`

It is working fine, but I'm not sure if that's the best solution. Just wanted to share it in case somebody else was experiencing the same issue.

Thank you for the tutorial and the code!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions