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

- **ID:** `python/flask-session-cookie-not-signed`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Flask applications using sessions must set a secret key via `app.secret_key`; without it, session operations raise a RuntimeError.

## Version Compatibility

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

## Workarounds

1. **** (100% success)
   ```
   Set `app.secret_key = 'your-secret-key'` in your app creation code, preferably from environment variables: `import os; app.secret_key = os.environ.get('SECRET_KEY', 'dev-key')`.
   ```
2. **** (95% success)
   ```
   If using an app factory, set it in `create_app()` before returning the app.
   ```

## Dead Ends

- **** — Setting `app.config['SECRET_KEY']` after the first request doesn't help; it must be set before any session is used. (90% fail)
- **** — Using an empty string as secret key still raises the error because Flask checks for truthiness. (95% fail)
