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.php
Filesconfig.php
in both:/admin/config.php
/config.php
define('HTTP_SERVER', 'https://yourdomain.com/admin/');
define('HTTPS_SERVER', 'https://yourdomain.com/admin/');
3. Fix the session path in
php.ini
php.ini
file 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_start
is Offphp.ini
file, check:session.auto_start = 0
session.auto_start = 1
, change it to0
and 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
.htaccess
Issues.htaccess
rules, they might block admin access.9. Upgrade OpenCart or Restore a Working Backup
10. Use the
opencart_error.log
to Debug Further/system/storage/logs/error.log
to 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. 🚀