Timur Malyshev
Timur Malyshev

Reputation: 51

Symfony 3. Cookie auto deletes immediately after create

I create cookie in EventSubscriber:

function onKernelResponse(FilterResponseEvent $event)
    {
        $response = new Response();
        $cookie_data = 'test';
        $cookie = new Cookie('test_cookie', $cookie_data, strtotime('now +1 year'));

        $response->headers->setCookie($cookie);
        $response->send();
}

then I watch to Application tab in Chrome and press F5. this cookie appears for 0.5 sec and automatically remove

what i am doing wrong?

Upvotes: 3

Views: 40

Answers (1)

Timur Malyshev
Timur Malyshev

Reputation: 51

I hope this helps somebody.

I found problem: nginx send missed static files like .jpg to application.

When i fix nginx vhost file - cookies starts to set correctly.

Upvotes: 2

Related Questions