title: How to Delete The Session and cookie in symfony2
body: <p>what I need</p>
  
  <ul>
  <li>i Need When user click logout cookie is deleted.</li>
  <li>code is working in chrome , mozilla.</li>
  <li>bug in mozilla ver 30 , Ie 10.</li>
  </ul>
  
  <p>php code</p>
  
  <pre><code>     public function flushAction() {
      $service = $this-&gt;get('acme.twig.acme_extension');
      $detect=$service-&gt;DomainDetect();
  
      if ($this-&gt;get('session')-&gt;get('user')) 
      {
  
          $session = $this-&gt;get('session');
          $ses_vars = $session-&gt;all();
          foreach ($ses_vars as $key =&gt; $value) {
          $session-&gt;remove($key);
          }
      }
  
  
          if(isset($_COOKIE['user']))
          {
          echo $_COOKIE['user'];
          echo "&lt;pre&gt;..........";
          unset($_COOKIE['user']);
          setcookie("user","",time() - 3000,"/",".10times.com");
          }
          if(isset($_COOKIE['user_flag']))
          {
               echo $_COOKIE['user_flag'];
               echo "&lt;pre&gt;..........";
          unset($_COOKIE['user_flag']);
          setcookie("user_flag",'',time() - 3000,"/",".10times.com");
          }
          if(isset($_COOKIE['email']))
          {
               echo $_COOKIE['email'];
                 echo "&lt;pre&gt;....";
          unset($_COOKIE['email']);
          setcookie("email",'',time() - 3000,"/",".10times.com");
          }
            if(isset($_COOKIE['name']))
          {
              echo $_COOKIE['name'];
                echo "&lt;pre&gt;.........";
          unset($_COOKIE['name']);
          setcookie("name",'',time() - 3000,"/",".10times.com");
          }
          if(isset($_COOKIE['id']))
          {
               echo $_COOKIE['id'];
                 echo "&lt;pre&gt;.........";
          unset($_COOKIE['id']);
          setcookie("id",'',time() - 3000,"/",".10times.com");
          }
          exit;
          //var_dump($_SERVER['HTTP_REFERER']);
          if(strstr($_SERVER['HTTP_REFERER'],$detect))
          {
  
              header("Location:".$_SERVER["HTTP_REFERER"],TRUE,301);   
              exit;
          }
          else
          {
              header("Location:".$detect,TRUE,301);
              exit;
          }
  
          exit;
  
  
    }
  </code></pre>
  
  <p>Snapshot of Resource</p>
  
  <ul>
  <li><p><img src="https://i.stack.imgur.com/aVSxd.png" alt="enter image description here"></p>
  
  <p>Debug</p></li>
  <li><p>i want to delete cookie and session .</p></li>
  <li>any suggestion are most welcome.</li>
  <li>i make call domainname.com/user/flush.</li>
  </ul>
  
  <p>solution i have tried</p>
  
  <pre><code>    $name = $this-&gt;getUser()-&gt;getAttribute('user', 'default_value');
      $this-&gt;getUser()-&gt;setAttribute('user', $value);
      $name-&gt;getAttributeHolder()-&gt;remove('user','','user_flag');
  </code></pre>
  
  <ul>
  <li><p>anthor solution </p>
  
  <pre><code> if ($this-&gt;get('session')-&gt;get('user')) 
  {
      $this-&gt;get('session')-&gt;remove('user');
  }
  </code></pre></li>
  <li><p>where i want to  delete session of user and user_flag variables.</p></li>
  </ul>