title: password hasing with php hash_hmac
body: <p>Existing Approach:</p>
  
  <pre><code>//$user_id = $row['UserID']; User Identifier
  //$token = uniqid($user_id,TRUE);
  //$salt = md5(mt_rand());
  //$cookie_id = hash_hmac('SHA512',$token,$salt);
  
  $expiry = strval(time() + (7 * 24 * 60 * 60));
  $cookie_name = "GETIN";
  //Store these data in DB
  setcookie("GETIN",$token,$expiry);
  </code></pre>
  
  <p>This is how i am generating cookie values and only setting <code>uniqid of userID and expiry time in client side</code> </p>
  
  <p>And when user logs in next time,</p>
  
  <pre><code>        $cookie_name = 'GETIN';
          $salt = getSalt($cookie_name,$connection);
          $cookie_id = getCookieID($cookie_name,$connection);
          echo "      cookieid=".$cookie_id ;
          echo "      salt=".$salt;
          if($cookie_id == (hash_hmac('SHA512',$_COOKIE['GETIN'],$salt)))
          {
              die('{"status":"success"}');
          }
  </code></pre>
  
  <p>This is how i am checking the status.</p>
  
  <p>What are the problems with this approach? Please let me know the problem with this type of cookie mechanism</p>