Sunday, 15 May 2011

php - Symfony2 PDO Session with Flashbag -


I am using Symfony 2.3.1 (this problem was also present in 2.2) with session.handler.pdo , But when I add a flash bag message like this:

  $ this-> Receive ('session') - & gt; GetFlashBag () - & gt; Add ('success', "Your message has been sent."); $ $ Return - ($ -> - URIRL ('Home'));   

Unless I refresh, after the redirect, it is not shown on the home page, then it shows. Therefore its 2 requests have to be displayed. If I change session storage back to native then this problem has ended. Why any thoughts are happening?

I use the following to print messages in Tweg

  {app.session.flashbag.get ('success') for Flash message {%} { {FlashMessage}} {% endfor%}   

and the documentation of my services is similar to:

  Services: PDO: class: PDO logic: DSN: "Mysql: dbname =% Database_Name%" user:% database_user% password:% database_password% call: - [setAttribute, [3, 2]] # \ PDO :: ATTR_ERRMODE, \ PDO :: ERRMODE_EXCEPTION Session.handler.pdo: class : Symfony \ Component \ HttpFoundation \ Session \ Storage \ Handler \ PdoSessionHandler Argument: ["@Pado",% pdo.db_options%]    

I could have a race condition similar to the memcache session.

When writing Flash and Redirect sequences, it may be:

  - Rental Redirection | -DB record-client saves access. Redirect url | | -DB caters to savings- Clinic refresh |   

In my case the solution was adding to AppKernel.php .

  public function handle (request $ request, $ type = HttpKernelInterface :: MASTER_REQUEST, $ catch = true) {$ response = original :: handle ($ request, dollar type, $ hold); If ($ type == HttpKernelInterface :: MASTER_REQUEST) {if ($ this-> getContainer () -> get ('session') -> Starred ()) // $ $ $ $ $ $ Save session before - & gt; GetContainer () - & gt; Mill ('session') - & gt; Save (); }} $ Reaction; }    

No comments:

Post a Comment