Fixing login mechanism, and adding security to pages when the user is not logged in