Laravel really depends on a million different things, so the code that I'm providing may or may not work, but we have used this for Laravel before. This might at least get someone started.
In the includes/config.php file, you need to include some files:
- Code: Select all
include_once( dirname(dirname(dirname(__FILE__))).'/bootstrap/autoload.php');
include_once( dirname(dirname(dirname(__FILE__))).'/bootstrap/app.php');
include_once( dirname(dirname(dirname(__FILE__))).'/app/Http/Controllers/Auth/app.php');
and the includes/integration.php file's get_user_id function:
- Code: Select all
function get_user_id()
{
$userid = NULL;
if (!empty($_COOKIE['laravel_session']))
{
$app = app();
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$id = $app['encrypter']->decrypt($_COOKIE[$app['config']['session.cookie']]);
$app['session']->driver()->setId($id);
$app['session']->driver()->start();
if($app['auth']->user()!= NULL){
$userid = $app['auth']->user()->id;
}
}
return $userid;
}