# Warning: session_start(): Session GC failed in /var/www/app/src/Session/SessionManager.php:35

- **ID:** `php/session-gc-probability-high`
- **Domain:** php
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

PHP's session garbage collection (GC) fails due to permission issues on the session save path, disk full, or a misconfigured GC probability that triggers too frequently.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| PHP 7.4 | active | — | — |
| PHP 8.0 | active | — | — |
| PHP 8.1 | active | — | — |
| PHP 8.2 | active | — | — |
| PHP 8.3 | active | — | — |

## Workarounds

1. **Fix permissions on the session save path: run 'sudo chmod 733 /var/lib/php/sessions' and 'sudo chown www-data:www-data /var/lib/php/sessions' (adjust user/group as needed).** (90% success)
   ```
   Fix permissions on the session save path: run 'sudo chmod 733 /var/lib/php/sessions' and 'sudo chown www-data:www-data /var/lib/php/sessions' (adjust user/group as needed).
   ```
2. **Check disk space with 'df -h' and free up space if necessary. If using tmpfs for sessions, ensure enough memory is allocated.** (85% success)
   ```
   Check disk space with 'df -h' and free up space if necessary. If using tmpfs for sessions, ensure enough memory is allocated.
   ```
3. **Reduce GC probability by setting session.gc_probability=1 and session.gc_divisor=1000 in php.ini to trigger GC once every 1000 requests, reducing load.** (75% success)
   ```
   Reduce GC probability by setting session.gc_probability=1 and session.gc_divisor=1000 in php.ini to trigger GC once every 1000 requests, reducing load.
   ```

## Dead Ends

- **** — Setting session.gc_probability=0 disables GC entirely, which prevents the warning but leads to session file accumulation and potential disk space issues. (80% fail)
- **** — Increasing session.gc_divisor to 1000 reduces GC frequency but does not fix underlying permission or disk problems; the warning may still appear sporadically. (65% fail)
