dflydev / dflydev-fig-cookies

Cookies for PSR-7 HTTP Message Interface.
MIT License
224 stars 29 forks source link

Why i'm cannot remove (expire) cookie, if use withPath method?.. #22

Closed musaev-haybulla closed 3 years ago

musaev-haybulla commented 8 years ago

If i set withPath method, i cannot remove or modify cookie any way.

This code sets a cookie that I can delete: $setCookie = SetCookie::create('auth')->withValue('1'); $response = FigResponseCookies::set($response, $setCookie);

but this code set cookie that i cannot remove (expire) and modify in Safari and Chrome (other browsers not verified) $setCookie = SetCookie::create('auth')->withValue('1')->withPath('/'); $response = FigResponseCookies::set($response, $setCookie);

What could it be?.. And how can I fix it?..

vincentsys commented 8 years ago

I am having a similar problem trying to remove a cookie $response = FigResponseCookies::set($response, SetCookie::create('token') ->withValue($token) ->withDomain('') ->withPath('/') );

after using $response = FigResponseCookies::expire($response, 'token');

I get an empty token as response with expiration in the past. But with the next GET a request is send with the old token value.

ve3 commented 6 years ago

I have the same problem. No one fix?

Tagirijus commented 6 years ago

In case somebody wants to know how I solved this:

public function removeCookie($response = null, $name = '')
    {
        $out = Dflydev\FigCookies\FigResponseCookies::remove($response, $name);
        return Dflydev\FigCookies\FigResponseCookies::set(
            $response,
            Dflydev\FigCookies\SetCookie::create($name)
                ->withPath('/')
                ->withExpires('Tue, 15-Jan-2013 21:47:38 GMT')
                ->withMaxAge(0)
        );
    }

I just set the expire date into the past by hand.

franzliedke commented 3 years ago

I went ahead with my proposal to deprecate the misleading facade methods in #45.