3

Here is my php.ini session settings

session.save_handler = redis
session.save_path    = tcp://127.0.0.1:63791

Here is my session info()

Session Support     enabled
Registered save handlers    files user redis rediscluster redis rediscluster
Registered serializer handlers  php_serialize php php_binary wddx igbinary
Directive   Local Value Master Value
session.auto_start  Off Off
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    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  1000    1000
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.hash_bits_per_character 5   5
session.hash_function   0   0
session.lazy_write  On  On
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    redis   redis
session.save_path   tcp://127.0.0.1:63791   tcp://127.0.0.1:63791
session.serialize_handler   php php
session.upload_progress.cleanup On  On
session.upload_progress.enabled On  On
session.upload_progress.freq    1%  1%
session.upload_progress.min_freq    1   1
session.upload_progress.name    PHP_SESSION_UPLOAD_PROGRESS PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix  upload_progress_    upload_progress_
session.use_cookies On  On
session.use_only_cookies    On  On
session.use_strict_mode Off Off
session.use_trans_sid   0   0

Here is the error I get when loading a page with a session_start

Fatal error: Uncaught RedisException: Connection closed in [no active file]:0 Stack trace: #0 {main} thrown in [no active file] on line 0

What am I doing wrong? Stack is Apache 2.4.18, Php7.01, Redis 2.2.5

1
  • Have you found the line that's causing the problem? Once you do, I found this ( no.php.net/manual/en/book.session.php ). I hope it helps. Commented Dec 29, 2015 at 0:58

1 Answer 1

4

Did you read: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-redis-server-as-a-session-handler-for-php-on-ubuntu-14-04

Make sure the php application does not overwrite the session.save_path ex:

ini_set("session.save_path","/tmp/");

If so you're settings are overwritten in the PHP application then the connection will fail.

Test your configuration in a separate php file:

<?php
var_dump(ini_get("session.save_handler"));
var_dump(ini_get("session.save_path"));

Run it from the console or web-browser. To verify the settings are correct also execute this piece of code in your application preferably as late as possible.

Most of times the ini settings in a framework(Zend, Symfony, etc) are overloaded in the bootstrap phase of that framework.

When the output of the var_dump is different than the separate PHP file, you probably need to adjust the framework settings. Read the documentation of the framework you're using.

You're asking something that could have lots of causes and effects. Depending on Infrastructure, Redis settings, firewall, PHP application/framework. You should be aware of that.

Sign up to request clarification or add additional context in comments.

1 Comment

Not on digital ocean. My settings are ok, but it crashes... Will update stack again and try again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.