A
A
Alexander2013-11-24 17:05:13
PHP
Alexander, 2013-11-24 17:05:13

How to permanently kill site cookies?

There is one small site. During authorization, the user is set cookies
setcookie('id', $id, time()+3600,$_SERVER['HTTP_HOST']);
Cookies are removed
on exit setcookie('id', '', time()-604800,$_SERVER['HTTP_HOST']);
but found one glitch in the module that works in a separate directory. The module displays that the cookies are intact after deletion, although they are not on the main page of the site.
I can not understand what the trouble is and why the cookies remain visible in the directory.
Tried all options.
How to delete cookies so that they are not available on both the main page and the directory?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nazar Mokrinsky, 2013-11-24
@zlobin

Your feeling is most likely correct, just pass not only the domain, but also the path to the page during the cookie setting (it is best to specify the root).

Y
Yuri Denisov, 2013-11-24
@denissov

In one project I have this, though the script was bought))

public static function destroySession() {
        $_SESSION = array();

        $params = session_get_cookie_params();

        setcookie(  session_name(), 
                    '', 
                    time() - 42000, 
                    $params["path"], 
                    $params["domain"], 
                    $params["secure"], 
                    $params["httponly"]
                );

        session_destroy();
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question