PrestaShop had been working fine until one night when I was on the Preferences page, I got automatically logged out after saving it. I thought it was normal but the auto-logout was persistent.
Everytime I re-logged in and clicked somewhere, I got automatically logged out and redirected to the login page. Browsing through the forums didn’t help – All the solutions didn’t work. And then I remembered a similar problem I had with Joomla and that my hosting provider solved it for me.
And sure enough, I found the working solution from a hosting provider.
Edit the Cookie.php File
So here’s what you should do. Download the cookie.php file using your FTP software. The file is inside the /classes folder.
Open cookie.php and look for these codes and delete them (or preferably comment them out):
if ($this->id_employee AND Validate::isUnsignedId($this->id_employee) AND Employee::checkPassword(intval($this->id_employee), $this->passwd) AND (!isset($this->_content['remote_addr']) OR $this->_content['remote_addr'] == ip2long(Tools::getRemoteAddr())))
Replace the codes above with this:
if ($this->id_employee AND Validate::isUnsignedId($this->id_employee) AND Employee::checkPassword(intval($this->id_employee), $this->passwd))
For version 1.4, look for the codes below and comment the first line out.
AND (!isset($this->_content['remote_addr']) OR $this->_content['remote_addr'] == ip2long(Tools::getRemoteAddr()))
It should look like this:
//AND (!isset($this->_content['remote_addr']) OR $this->_content['remote_addr'] == ip2long(Tools::getRemoteAddr()))
Now clear your browser cache and restart your browser. The auto-logout issues should be resolved now.
It worked for me; I hope it does for you. Good luck!
[/php]



Hi there, I am building a prestashop site.
Having trouble finding a solution for this one. I’m having a login-logout issue in the front office. So I sign in as a test user then when I click on another page like “home” or “shop by brand” I get logged out. There are some pages I can click on without getting logged out like the “my account”, “my wishlist”, “customer service” and the “shop by category” pages. But if I try to log in then visit the home page and a few other pages, the user gets logged out. Do you have any ideas/thoughts about what could be causing this? Where some pages you stay logged in and on other pages you get logged out…
Thanks for your help!! :)
Hi, i had the same issue with the 1.4.7.0 Prestashop.
with your specifications didn’t work, so i tuned a little bit :
AND (!isset($this->_content['remote_addr']) OR $this->_content['remote_addr'] == ip2long(Tools::getRemoteAddr()) OR
!Configuration::get(‘PS_COOKIE_CHECKIP’))
will be :
and ($this->_content['remote_addr'] == ip2long(Tools::getRemoteAddr()) OR
!Configuration::get(‘PS_COOKIE_CHECKIP’))
Thank you !
Cristi
April 5th, 2012
Azhar Kamar replied:
@Cristi, thanks for the valuable input!