{
  "id": "python/flask-cookie-setting-error",
  "signature": "AttributeError: 'Response' object has no attribute 'set_cookie'",
  "signature_zh": "属性错误：'Response' 对象没有 'set_cookie' 属性。",
  "regex": "AttributeError:\\ 'Response'\\ object\\ has\\ no\\ attribute\\ 'set_cookie'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "尝试在错误的响应对象上设置 cookie，例如在字符串或元组上调用。",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试在错误的响应对象上设置 cookie，例如在字符串或元组上调用。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "尝试直接返回字符串并调用 `set_cookie`，但字符串没有该方法。",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "尝试使用 `make_response` 但未正确赋值。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "使用 `response = make_response(render_template(...))` 然后调用 `response.set_cookie('key', 'value')`。",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "在返回前使用 `jsonify` 或 `Response` 对象。",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2026-04-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}