title: Pass variable from controller to another in Symfony?
body: <p>I have 2 actions functions in my controller and I want to pass  variable to an other action function</p>
  
  <p>This is my first function in my controller</p>
  
  <pre><code>public function newUserAction(Request $request)
  { ......... 
  $url = $this-&gt;generateUrl('userBundle_new_user_reasonCodeAjaxView',  
  array('id' =&gt; $newUser-&gt;getCode(),
              'countCode' =&gt; $countCode,));
              return $this-&gt;redirect($url);
  </code></pre>
  
  <p>This my second funtion in my controller</p>
  
  <pre><code>     public function userCodeAjaxViewAction(Request $request, $id)
  {
  
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $pc = $em-&gt;getRepository('UserBundle:Code')-&gt;find($id);
  
      if($pc != null)
      {
          return $this-&gt;render('UserBundle:userCodeView.html.twig', array(
           'pc' =&gt; $pc,
  
          ));
      }
  </code></pre>
  
  <p>And my twif looks like this</p>
  
  <pre><code>    &lt;div class=""&gt;
      &lt;div class="panel panel-default step3-textarea top-arrow top-arrow"&gt;
          &lt;div class="panel-body"&gt;
              &lt;fieldset&gt;
                   &lt;div&gt;
                      {{ pc.name|trans }}
  
       {{countCode}} 
  
                  &lt;/div&gt;
              &lt;/fieldset&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am getting an error <code>Variable "countCode" does not exist in...</code></p>
  
  <p>Is there any idea how I can use a variable from a controller in a other controller?</p>