title: Check if session exists in php
body: <p>In my php function here, i want to check if the session exists or not. based on the session existence i want to return true or false.</p>
  
  <p>i have a login function which uses <code>session_start();</code> and stores values into session variables when logged in, and when logged out it will do <code>session_destroy();</code></p>
  
  <p>now i want to check if the session exists or not.
  How can i do that</p>
  
  <pre><code>function ifsessionExists(){
      // check if session exists?
      if($_SESSION[] != ''){
      return true;
      }else{
      return false;
      }
  }
  </code></pre>