We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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?



9.7k
Accepted
answer
edited Apr '15

I found one solution. Use:

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

before

return $response;