Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Redirect with cookies

Hello, community. Please, help me.

When i set cookies

$this->getDI()->get('cookies')->set('sample_cookie','sample_value',time()+9000);

, and then do a redirect to another page

$response = new Response();
$response->redirect('sample/page');
return $response;

cookies are not set.

How i can make redirect to another page with all cookies that have been set in previous controller?



4.9k
Accepted
answer
edited Apr '15

I found one solution. Use:

$response->setCookies($thiss->getDI()->get('cookies'));

before

return $response;