<?php
/*
 * This file is part of the RedisBundle package.
 *
 * (c) Axel Etcheverry <axel@etcheverry.biz>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Euskadi31\Bundle\RedisBundle\Redis;

use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
use Redis;

/**
 * NativeRedisSessionStorage.
 *
 * Driver for the redis session save handler provided by the redis PHP extension.
 *
 * @see https://github.com/nicolasff/phpredis
 *
 * @author Axel Etcheverry <axel@etcheverry.biz>
 */
class NativeRedisSessionHandler extends NativeSessionHandler
{
    /**
     * Constructor.
     *
     * @param Redis $redis
     */
    public function __construct(Redis $redis)
    {
        ini_set('session.save_handler', 'redis');
        ini_set(
            'session.save_path',
            sprintf('tcp://%s:%d?persistent=0', $redis->getHost(), $redis->getPort())
        );
    }
}

<?php
/*
 * This file is part of the RedisBundle package.
 *
 * (c) Axel Etcheverry <axel@etcheverry.biz>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Euskadi31\Bundle\RedisBundle\Redis;

use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
use Redis;

/**
 * NativeRedisSessionStorage.
 *
 * Driver for the redis session save handler provided by the redis PHP extension.
 *
 * @see https://github.com/nicolasff/phpredis
 *
 * @author Axel Etcheverry <axel@etcheverry.biz>
 */
class NativeRedisSessionHandler extends NativeSessionHandler
{
    /**
     * Constructor.
     *
     * @param Redis $redis
     */
    public function __construct(Redis $redis)
    {
        ini_set('session.save_handler', 'redis');
        if($redis->getAuth() === null) {
            ini_set(
                'session.save_path',
                sprintf('tcp://%s:%d?persistent=0', $redis->getHost(), $redis->getPort())
            );
        } else {
            ini_set(
                'session.save_path',
                sprintf('tcp://%s:%d?persistent=0&auth=%s', $redis->getHost(), $redis->getPort(), urlencode($redis->getAuth()))
            );
        }
    }
}

Fix problem Auth when password was requested
Fix problem Auth when password was requested

English and French following:
A RedisException was thrown when redis was configured with a password

Adding a test to verify that the connexion use a password or not
Adding a parameters for auth in TCP

French:
Une RedisException était déclenchée lorsqu'on tentait d'utiliser un redis configurer avec un mot de passe

Ajout d'un test pour vérifier si Redis est configurer avec un mot de passe
Ajout d'un paramètre auth sur la requête TCP pour les redis avec mot de passe