Logout function and session handling added