/**
  * Determine if the session is using cookie sessions.
  *
  * @return bool
  */
 protected function usingCookieSessions()
 {
     if (!$this->sessionConfigured()) {
         return false;
     }
     return $this->manager->driver()->getHandler() instanceof CookieSessionHandler;
 }
 /**
  * @param RequestInterface $request
  * @return SessionInterface
  */
 private function getSession(RequestInterface $request)
 {
     $session = $this->manager->driver();
     $cookieData = FigRequestCookies::get($request, $session->getName());
     $session->setId($cookieData->getValue());
     return $session;
 }
 public function handleProviderCallback(Guard $auth, Socialite $socialite, UsersService $userService, SessionManager $manager)
 {
     $user = $socialite->driver('facebook')->user();
     $authUser = $userService->findOrCreateByFacebook($user);
     $auth->login($authUser);
     $manager->driver()->save();
     return redirect('/');
 }
Exemple #4
0
 public function startSession()
 {
     $encrypter = $this->createEncrypter();
     $manager = new SessionManager($this->laravel);
     $session = $manager->driver();
     $this->updateSessionId($encrypter, $session);
     $session->start();
     $this->bindNewSession($session);
 }
 /**
  * getSession.
  *
  * @method getSession
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Session\Store
  */
 protected function getSession($request)
 {
     $session = $this->sessionManager->driver();
     if ($session->isStarted() === false) {
         $session->setId($request->cookies->get($session->getName()));
         $session->setRequestOnHandler($request);
         $session->start();
     }
     return $session;
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app['session'] = $this->app->share(function ($app) {
         // First, we will create the session manager which is responsible for the
         // creation of the various session drivers when they are needed by the
         // application instance, and will resolve them on a lazy load basis.
         $manager = new SessionManager($app);
         $driver = $manager->driver();
         $config = $app['config']['session'];
         // Once we get an instance of the session driver, we need to set a few of
         // the session options based on the application configuration, such as
         // the session lifetime and the sweeper lottery configuration value.
         $driver->setLifetime($config['lifetime']);
         $driver->setSweepLottery($config['lottery']);
         return $driver;
     });
 }
Exemple #7
0
 /**
  * Get a driver instance.
  *
  * @param string $driver
  * @return mixed 
  * @static 
  */
 public static function driver($driver = null)
 {
     //Method inherited from \Illuminate\Support\Manager
     return \Illuminate\Session\SessionManager::driver($driver);
 }
 /**
  * Get the session implementation from the manager.
  *
  * @param  \Symfony\Component\HttpFoundation\Request  $request
  * @return \Illuminate\Session\SessionInterface
  */
 public function getSession(Request $request)
 {
     $session = $this->manager->driver();
     $session->setId($request->cookies->get($session->getName()));
     return $session;
 }
Exemple #9
0
// Not 100% sure on how many of these are needed
$container['config']['session.lifetime'] = 120;
// Minutes idleable
$container['config']['session.expire_on_close'] = false;
$container['config']['session.lottery'] = array(2, 100);
// lottery--how often do they sweep storage location to clear old ones?
$container['config']['session.cookie'] = 'laravel_session';
$container['config']['session.path'] = '/';
$container['config']['session.domain'] = null;
$container['config']['session.driver'] = 'file';
$container['config']['session.files'] = $path . '/sessions';
// Cookie time
$container['cookie'] = (new CookieJar())->setDefaultPathAndDomain('/', null);
// Now we need to fire up the session manager
$sessionManager = new SessionManager($container);
$container['session.store'] = $sessionManager->driver();
$container['session'] = $sessionManager;
// In order to maintain the session between requests, we need to populate the
// session ID from the supplied cookie
$cookieName = $container['session']->getName();
if (isset($_COOKIE[$cookieName])) {
    if ($sessionId = $_COOKIE[$cookieName]) {
        $container['session']->setId($sessionId);
    }
}
// Boot the session
$container['session']->start();
// END BOOTSTRAP---------------------------------------------------------------
// View
$app->get('/', function () use($container) {
    echo 'Current state of <code>$test</code>: ';
Exemple #10
0
 /**
  * __construct.
  *
  * @method __construct
  *
  * @param \Illuminate\Session\SessionManager $sessionManager
  */
 public function __construct(SessionManager $sessionManager)
 {
     $this->session = $sessionManager->driver();
 }
Exemple #11
0
 public function __construct(SessionManager $session, array $processors = null)
 {
     $this->processors = $processors;
     $this->session = $session->driver();
 }
 /**
  * elfinder.
  *
  * @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory
  * @param \Illuminate\Session\SessionManager            $sessionManager
  *
  * @return mixed
  */
 public function elfinder(ResponseFactory $responseFactory, SessionManager $sessionManager)
 {
     $token = $sessionManager->driver()->token();
     return $responseFactory->view('elfinder::elfinder', compact('token'));
 }
 /**
  * Perform any final actions for the request lifecycle.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Symfony\Component\HttpFoundation\Response  $response
  * @return void
  */
 public function terminate($request, $response)
 {
     if ($this->sessionHandled && $this->sessionConfigured() && !$this->usingCookieSessions()) {
         $this->manager->driver()->save();
     }
 }
Exemple #14
0
 /**
  * Get the session implementation from the manager.
  *
  * @return \Illuminate\Session\SessionInterface
  */
 public function getSession()
 {
     return $this->manager->driver();
 }
Exemple #15
0
Illuminate\Support\Facades\Facade::setFacadeApplication($app);
$app['app'] = $app;
$app['env'] = 'production';
$app['path'] = $basePath . '/app';
$app['path.lang'] = base_path('resources/lang');
$request = Illuminate\Http\Request::capture();
$app['request'] = $request;
/*load configure*/
$app['config'] = new Config(require base_path('config/config.php'));
/*end load configure*/
/*init new filesystem and register to container*/
$app['files'] = new Filesystem();
/*end init new filesystem and register to container*/
/*session manager*/
$sessionManager = new SessionManager($app);
$app['session.store'] = $sessionManager->driver();
$app['session'] = $sessionManager;
// In order to maintain the session between requests, we need to populate the
// session ID from the supplied cookie
$cookieName = $app['session']->getName();
if (isset($_COOKIE[$cookieName])) {
    if ($sessionId = $_COOKIE[$cookieName]) {
        $app['session']->setId($sessionId);
    }
}
// Boot the session
$app['session']->start();
/*end session manager*/
/*setup cookie*/
$cookie = new Cookie($app['session']->getName(), $app['session']->getId(), time() + $app['config']['session.lifetime'] * 60, '/', null, false);
setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain());