Created
January 15, 2014 10:39
-
-
Save 3onyc/8434142 to your computer and use it in GitHub Desktop.
Getting the Laravel session in a separate PHP file, honours session settings in config Laravel config.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once '/path/to/laravel/bootstrap/autoload.php'; | |
// Initialize the app | |
$app = require '/path/to/laravel/bootstrap/start.php'; | |
$request = $app['request']; | |
// Decrypt the cookies | |
$cookieGuard = new Guard($app, $app['encrypter']); | |
$cookieGuard->handle($request); | |
// Initialize the session | |
$session = $app['session.store']; | |
$session->setRequestOnHandler($request); | |
$session->setId($request->cookies->get($session->getName())); | |
$session->start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment