Only set session cookie if the user is logged in