Gracefully handling logouts and invalid session ids