How to set session variables for all the controllers in Symfony2?

后端 未结 3 916
不思量自难忘°
不思量自难忘° 2021-02-13 04:48

How do I create and access Symfony 2 session variables in my controllers. I used like this.

$session = new Session();
$session->start();
$session->set(\'lo         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-13 05:33

    One way of using Sessions in Symfony in controller is:

    setting:

    $this->get('session')->set('loginUserId', $user['user_id']);
    

    getting:

    $this->get('session')->get('loginUserId');
    

    If you use standard framework edition

提交回复
热议问题