Marginbaba

[SOLVED] Opencart 3.0.2.0 Admin login is not working?

One of the users asked the question in details in the comment section :
Hello Sir,
I have a website with the Opencart 3, But I am not able to login in the admin. I can change the password but the new password still not working. I am not getting any error on the admin page, I appreciate if you can help me?.

Here is the solution by Pradeep, we hope it will also help you to resolve the same issue.

We have found the obscure problem in Opencart 3 that was preventing to login in the admin panel, that’s why Opencart admin page not working. it had to do with the expiration set on the OCSESSID cookie. for some reason, using ini_get(‘session.cookie_lifetime’) was setting an expiration value on the cookie almost immediately. we took the same code that was used for setting the language and currency cookies. It will help you to resolve the Opencart session problem.

So how you can resolve the issue.
Just browse the file in Web-hosting directory system/framework.php
(You must download or backup this file before making any changes, do it at your own risk)

and find the below code.

Old code- which was not working

#setcookie($config->get(‘session_name’), $session->getId(), ini_get(‘session.cookie_lifetime’), ini_get(‘session.cookie_path’), ini_get(‘session.cookie_domain’));

New code – Which is working

setcookie($config->get(‘session_name’), $session->getId(), time() + 60 * 60 * 24 * 30, ini_get(‘session.cookie_path’), ini_get(‘session.cookie_domain’));

Now you can follow the same steps with another file
catalog/controller/startup/session.php
(You must download or backup this file before making any changes, do it at your own risk)

Old code

setcookie($this->config->get(‘session_name’), $this->session->getId(), ini_get(‘session.cookie_lifetime’), ini_get(‘session.cookie_path’), ini_get(‘session.cookie_domain’));

Replace this new code:

setcookie($this->config->get(‘session_name’), $this->session->getId(), (ini_get(‘session.cookie_lifetime’) ? (time() + ini_get(‘session.cookie_lifetime’)) : 0), ini_get(‘session.cookie_path’), ini_get(‘session.cookie_domain’));

Now edit php.ini file and add below line

session.cookie_lifetime = 360000

I have tested these changes in Opencart 3.0.2.0 version only, not tested with others.

Please let me know by comments if it solves your problem.

Thank you
Pradeep

 

 

 

Exit mobile version