-
-
Save nikosv/296f0bc16cbbae2fec98 to your computer and use it in GitHub Desktop.
Share Laravel 5 session and check authentication from external projects
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 | |
/* | |
|-------------------------------------------------------------------------- | |
| 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 5 | |
| | |
| Last update: 2015-03-17 | |
| | |
*/ | |
require '/path/to/laravel/bootstrap/autoload.php'; | |
$app = require_once '/path/to/laravel/bootstrap/app.php'; | |
$kernel = $app->make('Illuminate\Contracts\Http\Kernel'); | |
$response = $kernel->handle( | |
$request = Illuminate\Http\Request::capture() | |
); | |
$isAuthorized = Auth::check(); | |
Not sure why but this is only working for me on the base wordpress url. On example.com I can get the full Authorized Laravel user but if I go to example.com/directory/ it returns null.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So if I understand this, you are checking if the user is authenticated in Laravel, not in the Wordpress install, Joomla, or other CMS?