Improve cookie error handling