How to use session in custom class laravel 5?
Your use
needs to be after the namespace declaration:
//use Illuminate\Support\Facades\Session; //Not herenamespace App\CustomLibraryuse Illuminate\Support\Facades\Session; //Here
Anything that is use
d before the namespace is used within the global namespace which changes once a namespace is declared.
use Session; in Model and Controller
// Via a request instance...
$request->session()->put('key', 'value');
// Via the global helper...
session(['key' => 'value']);
for more details https://laravel.com/docs/5.1/session