Opencart - Unable To Login [Solved]
Posted by The Curious Website Designer | Posted on Fri 26 Jun 2020
I recently had a problem logging in to an Opencart administrators control panel. I entered the username and password correctly, and although the url in the browser address bar changed to the correct dashboard url , the page displayed was still the login page.
This situation arose shortly after I started experiencing problems with session data not being retained.
The Solution
After wasting a couple of days trying to get to the bottom of the problem, it turned out that the solution was quite straightforward.
For some reason, the table 'oc_session' had been changed so that the column 'session_id' no longer had a primary index.
I have no idea how this happened, but to fix this, I simply had to import the following sql query:
CREATE TABLE `oc_session` (
`session_id` varchar(32) NOT NULL,
`data` text NOT NULL,
`expire` datetime NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
This deletes the existing session table and then re-creates it in the correct format..
If that doesn't fix the problem, another possible fix is to edit the file 'system/framework.php' and find:
Replace with:
This will set the cookie length to 1 week.
This article is mainly for me, because I have encountered the problem before and ended up reinstalling the whole site. But if it helps someone else, that's great too.
Tags: opencart, login, login problems