Class ‘App\Http\Controllers\Session’ Not Found In Laravel


In this tutorial, we learn Class ‘App\Http\Controllers\Session’ not found in Laravel. The session variable is the global variable and use session, you need to session library. In laraval session need some store value and display flash message, etc.

If you faced this problem so go to your page and find use session under namespace.

Class ‘App\Http\Controllers\Session’ Not Found In Laravel- Step By Step

If you are getting error like Class ‘App\Http\Controllers\Session’ not found on controller in laravel.

So, add use Session; at the top of your controller file along with other prefixes:

use Session;
 
OR
 
use Illuminate\Support\Facades\Session;
Example:

Then YourController.php file, add use Session; at the top of your controller a file like the following:

<?php 
namespace App\Http\Controllers;
 
use Illuminate\Http\Request;
 
use Session;
 
class YourController extends Controller
{
    public function index(Request $request)
    {
        //your code
    }
 
}

I hope it can help you...

Leave a Reply

Your privacy will not be published. Required fields are marked *

We'll share your Website Only Trusted.!!