title: How do I keep a user logged in my website?
body: <p>I am using Facebook API to log in a user. It logs in a user successfully.</p>
  <p>But whenever I refresh the website or close it then reopen it logs out automatically. I don't need that I want a user logged in until he himself logs out of my website. How do I do it?</p>
  <p>This is my code:</p>
  <pre><code>function statusChangeCallback(response) {
  
  
      if (response.status === 'connected') {
          setElements(true);
          console.log('Logged in');
          instaInfo();
      } else {
          setElements(false);
          console.log('not logged in');
      }
  }
  
  function checkLoginState() {
      FB.getLoginStatus(function(response) {
          statusChangeCallback(response);
      });
  }
  
  function setElements(isLoggedIn) {
      if (isLoggedIn) {
          document.querySelector('#fb-btn').style.display = 'none';
          document.querySelector('.logout').style.display = 'block';
          document.querySelector('.navigation').style.display = 'block';
          document.querySelector('.nav-main').style.visibility = 'visible';
          document.querySelector('#container').style.display = 'block';
      } else {
          document.querySelector('#fb-btn').style.display = 'block';
          document.querySelector('.logout').style.display = 'none';
          document.querySelector('.navigation').style.display = 'none';
          document.querySelector('.nav-main').style.visibility = 'hidden';
          document.querySelector('#container').style.display = 'none';
      }
  }
  
  document.querySelector('.logout').addEventListener('click', () =&gt; {
      FB.logout(function() {
          setElements(false);    
          console.log('Logged Out!');
      });
  });
  </code></pre>