Support the ongoing development of Laravel.io →
Configuration Authentication Session
Last updated 2 years ago.
0

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();
}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

blyleven blyleven Joined 16 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.