title: How to create a condition if session is set?
body: <p>I have a form that posts some variables with jquery. I'm having trouble getting the php that processes the form to work as intended and can't figure out what I'm doing wrong. </p>
  
  <p>I want the form to do different things depending on the value of the <code>btn</code> variable but if the user is not logged in (user_session is empty) then a message is returned telling them so. What have I got wrong here?</p>
  
  <pre><code>&lt;?php
  session_start();
  //Check session is set
  if(isset($_SESSION['user_session']) &amp;&amp; !empty($_SESSION['user_session'])) { 
      $btn=$_POST['btn']; //Get btn name from form
      if ($btn=="btn_follow") {
          //Do something
      }
      elseif ($btn=='btn_unfollow') {
          //Do something else
      }
  echo "You need to be logged in";
  }
  ?&gt;
  </code></pre>