title: How do I correctly check for a cookie in Symfony2?
body: <p>I am trying to use twig annotation in my view to detect whether a certain cookie value has been set, but I'm not very familiar with twig and it's not currently working.</p>
  
  <p>First, I have set the cookie in a controller, and I can see that it is present from my browser. Here is the relevant PHP code:</p>
  
  <pre><code>if (isset($_GET['accept-cookie'])) {
      setcookie("acceptCookies", "true", time() + (86400 * 300));
  }
  </code></pre>
  
  <p>In my browser I can view the cookie and confirm that the content is correctly set to true.</p>
  
  <p>Now in my view I need to check that the cookie is present, if it is not then a cookie banner should be displayed. Here is the code:</p>
  
  <pre><code>{% if app.request.cookies.get("acceptCookies") != null %}
      &lt;h1&gt;Cookies are set!&lt;/h1&gt;
  {% else %}
      &lt;div id="cookieBanner"&gt;
          &lt;div id="cookieContainer"&gt;
              &lt;p&gt;We use cookies on this website. By using this website, we'll assume that you consent to &lt;a href="/cookies"&gt;the cookies we set.&lt;/a&gt;&lt;/p&gt;
              &lt;a href="?accept-cookie" class="button"&gt;Okay, continue.&lt;/a&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  {% endif %}
  </code></pre>
  
  <p>According to the documentation I've read this should work correctly, however, it continues to display the cookie banner even though I can see that the browser is present in my browser.</p>
  
  <p>How should I approach solving this?</p>