<p dir="auto">my conf:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="services:
    session.memcached:
        class: Memcached
        calls:
          - [ addServer, [ 127.0.0.1, 11211 ]]

    session.handler.memcached:
        class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
        arguments: [ @session.memcached, { prefix: zuo_session, expiretime: 3600 } ]

framework:
    session:
        handler_id: session.handler.memcached"><pre class="notranslate"><code class="notranslate">services:
    session.memcached:
        class: Memcached
        calls:
          - [ addServer, [ 127.0.0.1, 11211 ]]

    session.handler.memcached:
        class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
        arguments: [ @session.memcached, { prefix: zuo_session, expiretime: 3600 } ]

framework:
    session:
        handler_id: session.handler.memcached
</code></pre></div>
<p dir="auto">my controller:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    /**
     * @Route(&quot;/about&quot;,name=&quot;aboutMe&quot;)
     * @Template()
     */
    public function meAction()
    {
        $v=rand(1,9999);
        ld($v);
        $this-&gt;get('session')-&gt;set('aaaaaaaaa',$v);
        return new \Symfony\Component\HttpFoundation\RedirectResponse('/advice');
    }

    /**
     * @Route(&quot;/advice&quot;,name=&quot;aboutAdvice&quot;)
     * @Template()
     */
    public function adviceAction()
    {
        ld($this-&gt;get('session')-&gt;get('aaaaaaaaa'));
        return array('title' =&gt; 'aaa');
    }"><pre class="notranslate"><code class="notranslate">    /**
     * @Route("/about",name="aboutMe")
     * @Template()
     */
    public function meAction()
    {
        $v=rand(1,9999);
        ld($v);
        $this-&gt;get('session')-&gt;set('aaaaaaaaa',$v);
        return new \Symfony\Component\HttpFoundation\RedirectResponse('/advice');
    }

    /**
     * @Route("/advice",name="aboutAdvice")
     * @Template()
     */
    public function adviceAction()
    {
        ld($this-&gt;get('session')-&gt;get('aaaaaaaaa'));
        return array('title' =&gt; 'aaa');
    }
</code></pre></div>
<p dir="auto">so what I did is:<br>
1.generate a random number on page A<br>
2.dump the number<br>
3.Save the number into session on page A<br>
4.redirect to Page B<br>
5.dump the number which has been saved into session on page A</p>
<p dir="auto">Normally, I will get 2 same number on page A and page B</p>
<p dir="auto">but,some times, I will get the different number on Page B which has been save on last turn on Page A.</p>
<p dir="auto">I guess the problem is because the save function of session hasn't been called automatically?</p>
<p dir="auto">I have been hit with a very strange situation during these last 2 days. I have a custom security listener and provider that sends some emails to the user and the user's "godfather" when registering. Immediately after registering, the user is redirected to his personal area. The problem arises when from time to time, the user is logged out when redirected.</p>
<p dir="auto">Digging into the code, I can clearly see that the session is totally empty after the redirect, so no information about the user token is present. However, when I reload the page the session is perfectly filled and the user becomes logged in again. So I assumed that the session was still not written to disk (using native php file handler) when the user was redirected!</p>
<p dir="auto">So here is what I found out. When sending emails with the default SF mailer (Swift) some bg processing must be kept somewhere. I am using nginx + php-fpm so the <code class="notranslate">fastcgi_finish_request</code> function is called and the page is immediately flushed. But as there must be some kind of bg processing, the session is still not written to disk when the next request coming from the redirect hits the server and the session is empty.</p>
<p dir="auto">Comenting <code class="notranslate">fastcgi_finish_request</code> function call or not sending the emails seems to fix the problem so it has to be some problematic combination of those 2 things...but who knows!</p>
<p dir="auto">Any ideas?</p>