I rewrote the code and got it done. However I find the redirect is inconsistent and would like some advice on a solution.
Session.php
Checks the following states:
1. User not logged in because $_Session variable does not exist. Returns "Guest".
2. User log in expired because $_Session variable is less than the current server time. Returns "Expired".
3. User logged in and not expired. Returns "Active".
Session.js
Ajax gets output from Session.php and if Guest or Expired redirects to log-in page.
How do I construct the Session.js so that it does not load the body and it redirects if Guest or Expired is returned?