Added session checking to main pages, abstracted some session functionality to session