Question: I have created a session variable in one controller and I want to access it in another controller. In `loginsuccess` controller I set the session: 

```
$session->set('id',$id);

```

How can I access this variable in another controller?

Answer: 
There is `session` service which you should use:

```
$id = $this->get('session')->get('id');

```

or

```
$this->get('session')->set('id', $id);

```
On a more general note, if your controller extends from the base Symfony controller (`Symfony\Bundle\FrameworkBundle\Controller\Controller`) you can get the session in 3 ways:

1. `$session = $this->container->get('session');`
2. `$session = $this->get('session');` (which basically is a shortcut to 1)
3. `$session = $request->getSession();`