using optional for session invalidation