# AttributeError: 'Response' object has no attribute 'set_cookie'

- **ID:** `python/flask-cookie-setting-error`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

尝试在错误的响应对象上设置 cookie，例如在字符串或元组上调用。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   使用 `response = make_response(render_template(...))` 然后调用 `response.set_cookie('key', 'value')`。
   ```
2. **** (90% success)
   ```
   在返回前使用 `jsonify` 或 `Response` 对象。
   ```

## Dead Ends

- **** — 尝试直接返回字符串并调用 `set_cookie`，但字符串没有该方法。 (70% fail)
- **** — 尝试使用 `make_response` 但未正确赋值。 (60% fail)
