Failed to write session data, php and memcached

memcached, php

Solution

If you are using memcache then `save_path` must have the `tcp://` prefix.

If you are using memcached then the `save_path` should not have the `tcp://` prefix.

Problem

I have recently tried implementing memcached for session saving in php. I modified the session.save_handler in my php.ini and for the most part it works correctly. Sessions are saved in it. However, once in a while, I get this weird message for certain sessions: PHP Warning: Unknown: Failed to write session data (memcached). Please verify that the current setting of session.save_path is correct (x.x.x.x:11211) in Unknown on line 0. The session data is the same, way under the 1MB barrier of memcached and I have yet to see a pattern in the occurences of this message... maybe a couple of times every minute. The website is usually under medium load, 150 users concurrently.

Original source