Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dud3
Forked from frzsombor/gist:ddd0e11f93885060ef35
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dud3/831edc0e921aa7ed089c to your computer and use it in GitHub Desktop.
Save dud3/831edc0e921aa7ed089c to your computer and use it in GitHub Desktop.
<?php
/*
|--------------------------------------------------------------------------
| Sharing Laravel's session and checking authentication
|--------------------------------------------------------------------------
|
| Use the following code in any CMS (WordPress, Joomla, etc), filemanager (CKFinder,
| KCFinder, simogeos's Filemanager, etc), or any other non-Laravel project to boot into
| the Laravel framework, with session support, and check if the user is authenticated.
|
| The following code is tested with Laravel 4.2.11
| It may not work with Laravel 5
|
| Last update: 2015-01-09
|
*/
require '/path/to/laravel/bootstrap/autoload.php';
$app = require_once '/path/to/laravel/bootstrap/start.php';
$request = $app['request'];
$client = (new \Stack\Builder)
->push('Illuminate\Cookie\Guard', $app['encrypter'])
->push('Illuminate\Cookie\Queue', $app['cookie'])
->push('Illuminate\Session\Middleware', $app['session'], null);
$stack = $client->resolve($app);
$stack->handle($request);
$isAuthorized = Auth::check();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment