"라라벨 SessionManager"의 두 판 사이의 차이

(새 문서: ==개요== ;라라벨 <source lang='php'> <?php namespace Illuminate\Session; use Illuminate\Support\Manager; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSess...)
 
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 5개는 보이지 않습니다)
2번째 줄: 2번째 줄:
;라라벨  
;라라벨  


<source lang='php'>
<syntaxhighlight lang='php'>
<?php
<?php


121번째 줄: 121번째 줄:
     }
     }
}
}
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[라라벨 세션]]
* [[라라벨 Manager]]
* [[라라벨 Manager]]
* [[심포니 NullSessionHandler]]
* [[심포니 NullSessionHandler]]
* [[라라벨 Store]]
* [[라라벨 EncryptedStore]]
* [[라라벨 SessionServiceProvider]]
* [[라라벨 config/session.php]]


[[분류: Illuminate\Session]]
[[분류: Illuminate\Session]]

2020년 11월 2일 (월) 02:57 기준 최신판

1 개요[ | ]

라라벨
<?php

namespace Illuminate\Session;

use Illuminate\Support\Manager;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;

class SessionManager extends Manager
{
    protected function callCustomCreator($driver)
    {
        return $this->buildSession(parent::callCustomCreator($driver));
    }

    protected function createArrayDriver()
    {
        return $this->buildSession(new NullSessionHandler);
    }

    protected function createCookieDriver()
    {
        $lifetime = $this->app['config']['session.lifetime'];
        return $this->buildSession(new CookieSessionHandler($this->app['cookie'], $lifetime));
    }

    protected function createFileDriver()
    {
        return $this->createNativeDriver();
    }

    protected function createNativeDriver()
    {
        $path = $this->app['config']['session.files'];
        $lifetime = $this->app['config']['session.lifetime'];
        return $this->buildSession(new FileSessionHandler($this->app['files'], $path, $lifetime));
    }

    protected function createDatabaseDriver()
    {
        $connection = $this->getDatabaseConnection();
        $table = $this->app['config']['session.table'];
        $lifetime = $this->app['config']['session.lifetime'];
        return $this->buildSession(new DatabaseSessionHandler($connection, $table, $lifetime, $this->app));
    }

    protected function createLegacyDatabaseDriver()
    {
        $connection = $this->getDatabaseConnection();
        $table = $this->app['config']['session.table'];
        $lifetime = $this->app['config']['session.lifetime'];
        return $this->buildSession(new LegacyDatabaseSessionHandler($connection, $table, $lifetime));
    }

    protected function getDatabaseConnection()
    {
        $connection = $this->app['config']['session.connection'];
        return $this->app['db']->connection($connection);
    }

    protected function createApcDriver()
    {
        return $this->createCacheBased('apc');
    }

    protected function createMemcachedDriver()
    {
        return $this->createCacheBased('memcached');
    }

    protected function createWincacheDriver()
    {
        return $this->createCacheBased('wincache');
    }

    protected function createRedisDriver()
    {
        $handler = $this->createCacheHandler('redis');
        $handler->getCache()->getStore()->setConnection($this->app['config']['session.connection']);
        return $this->buildSession($handler);
    }

    protected function createCacheBased($driver)
    {
        return $this->buildSession($this->createCacheHandler($driver));
    }

    protected function createCacheHandler($driver)
    {
        $minutes = $this->app['config']['session.lifetime'];
        return new CacheBasedSessionHandler(clone $this->app['cache']->driver($driver), $minutes);
    }

    protected function buildSession($handler)
    {
        if ($this->app['config']['session.encrypt']) {
            return new EncryptedStore(
                $this->app['config']['session.cookie'], $handler, $this->app['encrypter']
            );
        } else {
            return new Store($this->app['config']['session.cookie'], $handler);
        }
    }

    public function getSessionConfig()
    {
        return $this->app['config']['session'];
    }

    public function getDefaultDriver()
    {
        return $this->app['config']['session.driver'];
    }

    public function setDefaultDriver($name)
    {
        $this->app['config']['session.driver'] = $name;
    }
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}