title: JavaScript Cookies check/set/delete
body: <p>I just wanna check if a cookie exists,
  set/reset the cookie for 1 day,
  and delete the cookie when the window/tab is closed</p>
  
  <p>I'm trying to do this in JavaScript, but hell JS is one dumbass language(I swear), add to that I'm stupid.</p>
  
  <p>Anyways here's what i'm doing:</p>
  
  <pre><code>function checkcookie(name)
  {
      //Can't figure this one out
      //I want to check wheather the cookie is set or not
      //if yes
      //{ reset cookie + ... }
      //else
      //{ set cookie + ... }
  }
  
  function setcookie(name,value,day)
  {
      var expireDate = new Date();
      expireDate.setSeconds(expireDate.getSeconds()+day*24*60*60*1000);
      document.cookie = name + "=" + value + ";path=/;expires=" + expireDate.toGMTString();
  }
  
  function delcookie(name)
  {
      setcookie(name,"",-1);
  }
  </code></pre>
  
  <p>Any kind of answer is appreciated and thx in advance.</p>