# RuntimeError: The session is unavailable because no secret key was set.  Set the secret_key on the application to something unique and secret.

- **ID:** `python/flask-secret-key-not-set`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

`app.secret_key` was never configured, so Flask cannot sign session cookies.

## Version Compatibility

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

## Workarounds

1. **** (97% success)
   ```
   import os
app.config['SECRET_KEY'] = os.environ['SECRET_KEY']
   ```
2. **** (95% success)
   ```
   import secrets
app.config['SECRET_KEY'] = secrets.token_hex(32)
   ```

## Dead Ends

- **** — Hard-coded weak key leaks via git and is insecure in production. (60% fail)
- **** — Cookie secure flag is unrelated to key availability. (95% fail)
