title: Logout and Delete Cookies [Redirect to main page]
body: <p>When user clicks the logout button from the main page, the cookies will be deleted and they will be redirected to window.location = url; . Even if user does not login, but instead clicks logout, they will still be redirected to window.location = url;. My codes are as below, I can't seem to logout even if I click the logout button and I will stay at the main page while being logged in. Can anyone tell what is wrong? I am new to JavaScript and I need help regarding this topic.</p>
  
  <pre><code>$('.logout-btn').click(function(e){
    e.preventDefault();
  
    if(isset($_COOKIE['REFERER']) &amp;&amp; $_COOKIE['REFERER'] != '') {
      window.location = url;
    }
    else {
      $.post(outurl, function( data ) {
      }).then(function(r){
        $('#popup_ok, .x-close').bind( "click", function() {
          window.location = url;
        });
        if(r.result == 1){
          popup_msg('Failed', r.msg);
        }
        else{
          popup_msg('Success', r.msg);
          setTimeout(function(){
            window.location = url;
          },2000);
        }
      });
    }
  });
  </code></pre>