N
N
Nikita Podosenov2020-07-02 18:31:16
PHP
Nikita Podosenov, 2020-07-02 18:31:16

Why are cookies different on different pages of the same site?

There is a site. Cookies are created in one file:

setcookie('login', 'login', time() + (31 * 24 * 60 * 60), "/");
setcookie('rights', 'user', time() + (31 * 24 * 60 * 60), "/");


In the folder below, these cookies are visible, but have their own meaning. That is, cookies have one meaning at one level and another at another. How to fix it?

PS Cookies deleted at the level below:
setcookie('login', 'login', time() - (31 * 24 * 60 * 60), "/");
setcookie('rights', 'user', time() - (31 * 24 * 60 * 60), "/");

When I try to delete them also, but at the level where they were created, nothing happens.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2020-07-02
@prizmer

To delete a cookie, you need to specify the one paththat was during installation.
For example, if you set a cookie with path = /user/auththen you will not be able to delete them by specifying path = /
. At the same time, the browser can store any number of cookies with the same name but different values path
. The same is true for cookies that are set with the domain name.

There is a site. Cookies are created in one file:

If you have different cookies at different levels, then apparently they were set earlier, when it was not specifiedpath = /

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question