Home » Php » php – How can I use Sessions in Laravel 6 Config File

php – How can I use Sessions in Laravel 6 Config File

Posted by: admin February 25, 2020 Leave a comment

Questions:

When I try to use session on config/database.php file.

I got errors:

First if I use

session('key');

Error: Target class [session] does not exist.

Secondary:

use Illuminate\Support\Facades\Session;
Session::get('key');

Error: A facade root has not been set.

I want to use session for database name.

How to&Answers: