I think I fixed it.

Okay, so what was happening was that it wasn't checking the cookie on
the login page. Now, it checks for it and!!! AND! I moved the login
check to a helper function.