简体   繁体   中英

PHP Session + Memcached => Mysterious Data Format

I have been using memcached as session.save_handler for a while and everything is working 100% fine.

Then I try:

echo $mycache->get('memc.sess.key.o8el2bgk4k9s1mr723j1blrgs3');

to fetch one of the sessions and the output is very strange (a string with 108 characters):

MaiiA6iX7qlS0IZjTdr2I3w4axNTp7H2IYcH-SAficGw5ZKIcMQ0BE2kFnsm4xHMk3KAJo9kOwmRTSBOPdPAC-m5L9CkWnYPONqujt5m0c8.

What format is this string in? For your info, here's the memcached configuration in phpinfo():

  • Directive Local Value Master Value
  • memcached.compression_factor 1.3 1.3
  • memcached.compression_threshold 2000 2000
  • memcached.compression_type fastlz fastlz
  • memcached.serializer php php
  • memcached.sess_binary 0 0
  • memcached.sess_lock_wait 150000 150000
  • memcached.sess_locking 1 1
  • memcached.sess_prefix memc.sess.key. memc.sess.key.

So it should have been in this format:

user_name|s:5:"guest";user_id|s:1:"3";user_level|s:2:"-1";

instead of the strange string.

Note: I am using memcached + php-memcached. Not memcache, and not php-memcache. Thanks.

I find the culprit! suhosin.session.encrypt.

ps I am fetching data from memcached directly, because I am testing WebSocket and one has to pass the session ID using JS manually. Then I need to get the session variables for that ID by myself :D

PHP会话使用各自的功能进行编码/解码-请参见session_decode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM