title: Cookies and sessions
body: <p>I would like to know the proper way to create and destroy session's / cookies.</p>
  
  <p>I use the following:</p>
  
  <p>To create a session / cookie value:</p>
  
  <pre><code>session_start();
  $_SESSION['SMUsername'] = $Username;
  
  setcookie("SMUsername",$Username, time()+86400, "/","www.Domain.com","False","True");
  </code></pre>
  
  <p>To destroy a session / cookie value:</p>
  
  <pre><code>session_destroy();
  
  if(isset($_COOKIE['SMUsername'])){
      setcookie("SMUsername","", -1, '/');    
  }
  </code></pre>
  
  <p>Is this a good way, or is this 'not done'?</p>
  
  <p>Furthermore, I have read in the following topic:
  <a href="https://stackoverflow.com/questions/686155/remove-a-cookie">Remove a cookie</a></p>
  
  <p>It says to never store a cookie with username and/or password information. How else can you use a functionality like remember me, without a cookie? </p>
  
  <p>I use the cookie to remember the user when a new browser is openend. (encrypted though, with md5)
  When re-opening the website, with another tab, I use a session to remember the user. Is this okay?</p>