fixed the logout function and added cookie validation to all restricted pages.