I just wanted to post back to this thread, as I looked all over the internet for a working example and could not find anything that worked. Here is the code that works for me. Obviously the file paths of your Laravel install could differ, but this is how I did it. I have tested this with Laravel 4.2 and works 100% as intended. Hopefully this code will save the next person some time.
protected function getUser()
{
require $_SERVER['DOCUMENT_ROOT'].'/../bootstrap/autoload.php';
$app = require $_SERVER['DOCUMENT_ROOT'].'/../bootstrap/start.php';
$id = $app['encrypter']->decrypt($_COOKIE[$app['config']['session.cookie']]);
$app->boot();
$app['session']->driver()->setId($id);
$app['session']->driver()->start();
return $app['auth']->driver()->user();
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community