Extend Your Session Logout Time in Magento 2
Getting logged out of the Magento admin panel while working on something? The default session timeout is 900 seconds (15 minutes), which can be frustrating during longer tasks. This guide shows you how to extend it.
Quick Configuration
Via Admin Panel
- Go to Stores → Configuration
- Navigate to Advanced → Admin → Security
- Find Admin Session Lifetime (seconds)
- Enter your preferred duration in seconds
- Click Save Config
- Clear cache
Common Values
| Duration | Seconds |
|---|---|
| 15 minutes (default) | 900 |
| 30 minutes | 1800 |
| 1 hour | 3600 |
| 2 hours | 7200 |
| 4 hours | 14400 |
| 8 hours | 28800 |
Via Command Line
You can also set this via CLI:
bin/magento config:set admin/security/session_lifetime 7200
bin/magento cache:flush
Security Considerations
While longer sessions are convenient, they also increase security risk:
- Public or shared computers - Keep timeout short (15-30 min)
- Private workstation - Longer timeout is acceptable (2-4 hours)
- PCI compliance - May require specific timeout limits
Recommendation: Don't exceed 4 hours (14400 seconds). If you need longer sessions, consider why and whether it's a security concern.
Related Settings
Password Lifetime
How long before admin passwords must be changed:
Location: Stores → Configuration → Advanced → Admin → Security → Password Lifetime (days)
Set to 0 to disable forced password changes.
Maximum Login Failures
Lock account after failed login attempts:
Location: Stores → Configuration → Advanced → Admin → Security → Maximum Login Failures to Lockout Account
Default is 6 attempts.
Lockout Time
How long account stays locked:
Location: Stores → Configuration → Advanced → Admin → Security → Lockout Time (minutes)
Default is 30 minutes.
Frontend Session Timeout
Customer sessions are separate from admin sessions. To adjust frontend session timeout:
- Go to Stores → Configuration
- Navigate to Customers → Customer Configuration → Online Customers Options
- Adjust Online Minutes Interval
Or for cookie lifetime:
Stores → Configuration → General → Web → Default Cookie Settings → Cookie Lifetime
Troubleshooting
Still Getting Logged Out
If you're still being logged out despite increasing the timeout:
- Check PHP session settings -
session.gc_maxlifetimeinphp.inishould be >= your Magento setting - Check Redis/session storage - If using Redis for sessions, verify TTL settings
- Check load balancer - Some load balancers have their own timeout settings
- Browser extensions - Some security extensions clear cookies
Setting Not Saving
If the configuration doesn't save:
bin/magento cache:flush
bin/magento config:show admin/security/session_lifetime
Check if value is locked in app/etc/config.php or env.php.
Session Cookie Issues
If sessions work but cookies don't persist:
- Check cookie domain settings in Stores → Configuration → General → Web → Default Cookie Settings
- Ensure your domain matches the cookie domain
- Check for HTTPS/HTTP mismatches
Need More Help?
Documentation:
- All Help Articles - Complete documentation overview
Support:
- Contact Support - Get help from our team