When trying to log in to the OpenCart admin panel (/admin), you are either:
- Stuck on the login page even after entering the correct credentials.
- Experiencing a redirect loop that returns you to the login screen without error.
- Seeing an error like
Invalid token session. Please login again.
This issue commonly happens due to incorrect session settings, incorrect paths in the config files, or browser cookie conflicts.
1. Clear Your Browser Cache & Cookies
2. Check Your OpenCart
config.phpFilesconfig.phpin both:/admin/config.php/config.phpdefine('HTTP_SERVER', 'https://yourdomain.com/admin/');
define('HTTPS_SERVER', 'https://yourdomain.com/admin/');
3. Fix the session path in
php.iniphp.inifile and find this line:session.save_path = "/var/lib/php/sessions"
4. Delete OpenCart Sessions & Cache Manually
rm -rf system/storage/cache/*
rm -rf system/storage/session/*
5. Ensure Your
session.auto_startis Offphp.inifile, check:session.auto_start = 0
session.auto_start = 1, change it to0and restart your web server.6. Reset Admin User Password (via Database)
UPDATE oc_user SET password = SHA1('newpassword') WHERE username = 'admin';
'newpassword'with your new password.7. Disable Extensions via Database (If an Extension is Causing Issues)
UPDATE oc_extension SET status = '0' WHERE type = 'module';
8. Check for Security Modifications or
.htaccessIssues.htaccessrules, they might block admin access.9. Upgrade OpenCart or Restore a Working Backup
10. Use the
opencart_error.logto Debug Further/system/storage/logs/error.logto identify any underlying issues.Comments:
This problem is often caused by incorrect session settings or cookie conflicts. If all else fails, try logging in from a different browser or device. 🚀