CakePHP Session ist lost after redirect
<p>In a Project i am using CakePHP 2.8.6. I am developing on my local environment (Macbook with Apache/2.4.23 (Unix) and PHP/5.6.16, MariaDB in a vagrant virtual machine) using git to deploy to the production server. The Project is set up to use the database for storing Sessions. When using </p>

<pre><code>$this-&gt;Flash-&gt;danger('Error_msg');
return $this-&gt;redirect(array('action' =&gt; 'view/'.$id));
</code></pre>

<p>the Cookie and database entries are getting stored and the database contains the Error_msg. However, after redirecting to view/id the message is not shown to the user and remains stored in the database.</p>

<p>When i remove the return statement the Message is shown and the database entry is cleared. But it is not the desired way.</p>

<p>Now the funny part:
When i deploy to the production server, everything works fine. The production server is running nginx 1.6.2 with php-fpm 5.6.24 and MariaDB 10.0.26. Even after the redirect the message is shown. Just to make clear: for development i am using Debug = 2, on the production machine Debug = 0.</p>

<p>I cannot figure out why this is not working on my local development environment. I installed a vagrant virtual machine just a few minutes ago, containing nginx 1.6.2 and php-fpm 5.6.24 and MariaDB 10.0.26 and even there it is not working. The production server is the only environment where the message gets shown correctly after the redirect. I compared the config files on the prod-server and the vagrant-machine but can't find major differences besides the hostname etc.</p>

<p>Anyone who can help figure this out? I can't test and develop anything using Sessions without this part working as expected...</p>

<p>edit: on the virtual machine i did set debug to 0 but no messages are shown. Even if i set debug to 0 on the dev env it is not working.</p>

<p>edit 2: In the AppController i have the following configuration:</p>

<pre><code>public $helpers = array('Html', 'Form', 'Flash');
public $components = array('RequestHandler', 'Cookie', 'Session', 'Flash');
</code></pre>