title: How Check current PHP session set or unset
body: <p>Guys in my php project i want to check on Login page session's status..if its unset i want user to login.
  ihave added this code to login page but it doesn't help as it loops.</p>
  
  <pre><code>if (strlen(session_id()) &lt; 1) {
      ?&gt;
      &lt;script&gt;window.location.href="login.php";&lt;/script&gt;  
      &lt;?php     
  }
  elseif(strlen(session_id()) &gt; 1){ 
      ?&gt;   
      &lt;script&gt;window.location.href="index.php";&lt;/script&gt;   
      &lt;?php 
  }
  </code></pre>
  
  <p>Now other thing I want is if session is already started and if user manually tries to go on login page from address bar he should be redirected back to that current page.</p>
  
  <p>If he is not logged in he should be redirected back to login page if he tries to open directly any page.  </p>
  
  <p>Also a new doubt with this is<br>
  Guys i m using wamp server to run my PHP projects.I have used PHP sessions in my projects,Now when a user logins from one project the sessions get set and if on same pc if user open some other project which are not linked to each other he gets directly logged in without even doing it, if he logouts from one project he gets logout from all other project running on that pc.</p>