memcached Session Problem - solved

I think I have a problem with sessions on my new Linux hosting.

Dolibarr 8.0.1 and 9.0.0 have the same issue.

I have the exact same set up working on hosting provided by 1and1. Same database, same installation.

I have tried changing the PHP versions, all versions 5.6 to 7.1 work on the old hosting, none fix the problem on the new hosting.

The problem is this:

  • Search box is blank
  • I have to login again when I navigate to pages other than Home

Everything else appears to be correct and working.

What I can see is that my old hosting had file based sessions and the new hosting has memcached sessions.

If I inspect the page to see what has gone wrong, it seems the PHP that builds the search box is encountering an error because it’s missing a field.

The error reported is:

jquery.min.js?layout=classic&version=9.0.0:2 Uncaught ReferenceError: select2arrayoflanguage is not defined
at HTMLDocument.<anonymous> (index.php?mainmenu=home:962)
at j (jquery.min.js?layout=classic&version=9.0.0:2)
at k (jquery.min.js?layout=classic&version=9.0.0:2)

Of course I may be completely off track but would really appreciate some help.

This is not a pb of memcached. It seems your browser use a wrong version of js files.
Try to clean your browser cache.

Thank you very much. I spent hours on this!

The same problem affected two separate users (that usually use different browsers) so I failed to think of a browser cache issue.

A full wipe of all browser history, cache etc, from Chrome has restored the Search box - fantastic. The pages are no longer showing errors.

There is still a small session type issue though, I am still getting logged out when I execute the search or navigate away from home. This maybe a simple config issue or something I broke whilst investigating.

Even after logging out and closing the browser window, when I come back to my bookmarked page I seem to be logged in, I see my home page. Only when I try the search or navigate around does it take me to the login page. Once logged in it’s all OK.

I’ve solved the problem with having to login twice.

The problem was this, whilst trying to solve the problem with the search not working I added a php.ini file in the root folder of the Dolibarr installation. I set various defaults trying to flush out the problem…however this php.ini file included:

session.auto_start = Off;
session.use_only_cookies = On;
session.use_cookies = On;
session.use_trans_sid = Off;
session.cookie_httponly = On;
session.gc_maxlifetime = 3600;

Which was different to the default settings for the server. Those included “session.save_handler = memcache” and a few other differences.

As we all know…php.ini only works for the current folder… that means pages in different folders would be using different php session settings.

So be careful using php.ini to change settings because they won’t apply to all the subfolders Dolibarr uses.

php.ini works on all subfolders. But you must restart apache after you’ve chaged it, because it’s only read by the start of PHP - which in turn happens when you (re)start apache.