0

i am trying to use memcached to store sessions but it seems session_start fails when trying to use the handler i used this simple script to see what is happening

ini_set('error_reporting', E_ALL);
echo ini_get("session.save_handler").'<br>';
echo ini_get('session.save_path').'<br>';
echo(var_export(session_start(), true)).'<br>';
ini_set("session.save_handler",'files');
ini_set('session.save_path', '/tmp');
echo ini_get("session.save_handler").'<br>';
echo ini_get('session.save_path').'<br>';
echo(var_export(session_start(), true));

which outputs this

memcached
127.0.0.1:11211
false
files
/tmp
true

this is my configuration

memcache
memcache support    enabled
Active persistent connections   0
Version 2.2.7
Revision    $Revision: 327750 $
Directive   Local Value Master Value
memcache.allow_failover 1   1
memcache.chunk_size 8192    8192
memcache.default_port   11211   11211
memcache.default_timeout_ms 1000    1000
memcache.hash_function  crc32   crc32
memcache.hash_strategy  standard    standard
memcache.max_failover_attempts  20  20

these are my session settings

session
Session Support enabled
Registered save handlers    files user memcache sqlite
Registered serializer handlers  php php_binary wddx
Directive   Local Value Master Value
session.auto_start  Off Off
session.bug_compat_42   On  On
session.bug_compat_warn On  On
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   xxxxxx.com  no value
session.cookie_httponly Off Off
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_file    no value    no value
session.entropy_length  0   0
session.gc_divisor  100 100
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.hash_bits_per_character 4   4
session.hash_function   0   0
session.name    CMSSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    memcached   memcached
session.save_path   127.0.0.1:11211 127.0.0.1:11211
session.serialize_handler   php php
session.use_cookies On  On
session.use_only_cookies    Off On
session.use_trans_sid   0   0
Traveling_Monk
  • 778
  • 2
  • 11
  • 28
  • This should be of some help: http://stackoverflow.com/q/13946033/2518525 – Darren Sep 16 '14 at 01:45
  • thx @Darren but the question at this time is not whether to use it or not, but why it doesn't work, though i am confused regarding memcache vs memcached one uses the tcp protocol the other not... – Traveling_Monk Sep 16 '14 at 02:05
  • I mean't the way you set it up could possibly be causing the issues that you're facing. That questions' content was the closest I deemed reliable to suit your issue, not the problem they were facing! :) – Darren Sep 16 '14 at 02:11
  • your probably right, the configuration is the problem, i didn't install it, but would like to make it work, i appreciate any debugging hints or maybe someone can see that a setting above is just wrong.... – Traveling_Monk Sep 16 '14 at 18:12
  • Is there anything in your apache error logs? – Darren Sep 16 '14 at 23:18
  • @Darren nope nothing related in the error_log – Traveling_Monk Sep 19 '14 at 07:26

1 Answers1

1

I follow this php-sessions-not-being-saved-in-memcache and able to find the direction to resolve my problem.

At first I only set the session.save_handler = memacache, then php errors popup said it failed to start.

Then I set the session.save_path = "tcp://127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15" and it works.

I am not sure if it is your problem too. Hope it helps.

Community
  • 1
  • 1
jeffsama
  • 1,597
  • 1
  • 9
  • 7