Updated to capture cookies on failure