I have an application and I need to store some information in cookies. I have an index page and put some piece of information into cookie (for example, some variable name). Index page cookie has path /Main/
. In another page I need to read this cookie and if necessary modify it. But another page cookie path is /Main/info/
. Browser just creates a new cookie, but I need to override it and use the same cookie with path /Main/
on all pages.
How can I do that?
Add path=/; or specify a path when you create the cookie. This will prevent the browser from creating duplicate cookies per domain.
To one of the comments, if you look at Google Chrome and how it displays the cookies it will show you the path. If you use the same cookie name without specifying the path it will create a cookie for each.
Note: Internet Explorer doesn't do the same thing, it has the single text file per domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With