How to get Larvel5.3 session data or Authentication data from public directory?
<p>I wrote some php function in public directory because I have to use external library. 
Then I can't retrieve any session data and authentication data from the controller I have tested with below php script</p>

<pre><code>session_start();
var_dump($_SESSION['user']);
</code></pre>

<p>I have initial Session data from AdminMiddlware already
It awesome for using it in Resource->view directories but can not in public.</p>

<pre><code>namespace App\Http\Middleware;

use App\User;
use Closure;
use Illuminate\Support\Facades\Auth;

class AdminMiddleware
{

/**
 * Handle an incoming request. User must be logged in to do admin check
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @return mixed
 */

public function handle($request, Closure $next)
{

    $user = User::find(\Auth::user()-&gt;id);
    if ((int) $user-&gt;is_admin == (int) config('auth.guards.is_admin')) {

        $collection = collect(Auth::user());
        $thisdata   = $collection-&gt;toArray();
        $request-&gt;session()-&gt;put('user', $thisdata);

        return $next($request);
    }

    return redirect()-&gt;guest('/');

}}
</code></pre>