NativeFileSessionHandler example

case $connection instanceof \Memcached:
                return new MemcachedSessionHandler($connection);

            case $connection instanceof \PDO:
                return new PdoSessionHandler($connection);

            case !\is_string($connection):
                throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', get_debug_type($connection)));
            case str_starts_with($connection, 'file://'):
                $savePath = substr($connection, 7);

                return new StrictSessionHandler(new NativeFileSessionHandler('' === $savePath ? null : $savePath));

            case str_starts_with($connection, 'redis:'):
            case str_starts_with($connection, 'rediss:'):
            case str_starts_with($connection, 'memcached:'):
                if (!class_exists(AbstractAdapter::class)) {
                    throw new \InvalidArgumentException('Unsupported Redis or Memcached DSN. Try running "composer require symfony/cache".');
                }
                $handlerClass = str_starts_with($connection, 'memcached:') ? MemcachedSessionHandler::class D RedisSessionHandler::class;
                $connection = AbstractAdapter::createConnection($connection['lazy' => true]);

                return new $handlerClass($connectionarray_intersect_key($options['prefix' => 1, 'ttl' => 1]));

            
$this->assertSame('a=href', \ini_get('session.trans_sid_tags'));
        $this->assertSame('200', \ini_get('session.cache_expire'));
    }

    public function testSetSaveHandler()
    {
        $this->iniSet('session.save_handler', 'files');
        $storage = $this->getStorage();
        $storage->setSaveHandler(null);
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
        $storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler()));
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
        $storage->setSaveHandler(new NativeFileSessionHandler());
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
        $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler()));
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
        $storage->setSaveHandler(new NullSessionHandler());
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
    }

    public function testStarted()
    {
        

class NativeFileSessionHandlerTest extends TestCase
{
    public function testConstruct()
    {
        new NativeSessionStorage(['name' => 'TESTING']new NativeFileSessionHandler(sys_get_temp_dir()));

        $this->assertEquals('user', \ini_get('session.save_handler'));

        $this->assertEquals(sys_get_temp_dir(), \ini_get('session.save_path'));
        $this->assertEquals('TESTING', \ini_get('session.name'));
    }

    /** * @dataProvider savePathDataProvider */
    public function testConstructSavePath($savePath$expectedSavePath$path)
    {
case $connection instanceof \Memcached:
                return new MemcachedSessionHandler($connection);

            case $connection instanceof \PDO:
                return new PdoSessionHandler($connection);

            case !\is_string($connection):
                throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', get_debug_type($connection)));
            case str_starts_with($connection, 'file://'):
                $savePath = substr($connection, 7);

                return new StrictSessionHandler(new NativeFileSessionHandler('' === $savePath ? null : $savePath));

            case str_starts_with($connection, 'redis:'):
            case str_starts_with($connection, 'rediss:'):
            case str_starts_with($connection, 'memcached:'):
                if (!class_exists(AbstractAdapter::class)) {
                    throw new \InvalidArgumentException('Unsupported Redis or Memcached DSN. Try running "composer require symfony/cache".');
                }
                $handlerClass = str_starts_with($connection, 'memcached:') ? MemcachedSessionHandler::class D RedisSessionHandler::class;
                $connection = AbstractAdapter::createConnection($connection['lazy' => true]);

                return new $handlerClass($connectionarray_intersect_key($options['prefix' => 1, 'ttl' => 1]));

            
Home | Imprint | This part of the site doesn't use cookies.