Hello,

With symfony2, I'm looking for the best way to automatically set the
locale of a user on his first connexion, based on what is advertised
by his browser.

What I've done so far is to implement an EventListener that provides
the onCoreRequest method:
  public function onCoreRequest( GetResponseEvent $event )
  {
    $request = $event->getRequest();
    $session = $request->getSession();
    if( $session ) {
      $locale = $session->get( 'locale', $request-
>getPreferredLanguage() );
      if( $locale !== null )
        $session->setLocale( $locale );
    }
  }

Since I also want to let the user choose another language, I track in
the session-variable called 'locale' (maybe misleading) any forced
setting, set by a controller.


So I was wondering if it is possible to have an event triggered when a
new session is created (i.e. with a new cookie).

Thanks for your tips & advices
Michel

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to