logout functionality and session check