Added logout functionality

Added a logout function and button, and fixed some session code.