Looking-up PHP sessions in memcached

Submitted by HighKing on Fri, 06/13/2014 - 09:57

If, like me, you use memcached primarily for storing php-sessions using the php-module 'memcache' or 'memcached', then you probably have no idea what's actually happening inside memcached. It took me some time to figure out simply how to lookup a php-session.

Like most things in life, the answer is actually pretty simple.

You need two things:
- The session name (can be found in php.ini / phpinfo()), usually just "PHPSESSID".
- The session id (I've used Firefox add-on "view cookies" to see mine).

In a telnet-session to your memcached-server you can lookup the session information with:

get <session name> <session id>

This has helped me a lot debugging a sessions-issue with a memcached-server involved. :-)