Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

harristars's avatar

hi guys please help i am new in laravel 5.3.16 Class 'session' not found

FatalErrorException in fa17d9d6b5a07c22ff5e6c69223c8360c8d5d8ae.php line 23: Class 'session' not found
0 likes
11 replies
tomopongrac's avatar

Is there somewhere in your code you call class session (all in lowercase)

harristars's avatar

no there is no place i have introduced the class session on my code

mahmandev's avatar

I'm not sure about this, I think those files with big names are cached views in storage\framework\views. So check your views.

harristars's avatar

i have seen the file and the error then after disabling this part of code


@section('title')
    Enterprenuer Base
@endsection

@section('content')
   <div class="row">
        <div class="col-md-6">
            <h3>Sign Up</h3>
            <form action="{{ route('signup') }}" method="post">
                <div class="form-group">
                    <label for="email">your E-mail</label>
                    <input class="form-control" type="text" name="email" id="email">
                </div>
                <div class="form-group">
                    <label for="first_name">First Name</label>
                    <input class="form-control" type="text" name="first_name" id="first_name">
                </div>
                <div class="form-group">
                    <label for="password">Password</label>
                    <input class="form-control" type="password" name="password" id="password">
                </div>
                <button type="submit" class="btn btn-primary">Submit</button>
                <!--input type="hidden" name="_token" value="{{ session::token() }}"-->
            </form>   
        </div> 
        <div class="col-md-6">
            <h3>Sign In</h3>
            <form action="#" method="post">
                <div class="form-group">
                    <label for="email">Your E-mail</label>
                    <input class="form-control" type="text" name="email" id="email">
                </div>
                <div class="form-group">
                    <label for="password">Password</label>
                    <input class="form-control" type="password" name="password" id="password">
                </div>
                <button type="submit" class="btn btn-primary">Submit</button>
            </form>
        </div>
   </div>
@endsection
willvincent's avatar
Level 54

Clear view cache: php artisan view:clear

if you're trying to include the csrf token, you do that like this:

{{ csrf_field() }}
1 like
harristars's avatar
<!--input type="hidden" name="_token" value="{{ session::token() }}"-->

after disabling that part of the code the systling have disappeared

harristars's avatar

@ willvincent i have cleared the caches but nothing changes

popcone's avatar

@jonimwangi45@gmail.com Use php comment (<?php /* */ ?>) or blade comment. Or just remove that line from your code.

If your intention is to include csrf token, use {{ csrf_field() }} as @willvincent said.

@section('title')
    Enterprenuer Base
@endsection

@section('content')
   <div class="row">
        <div class="col-md-6">
            <h3>Sign Up</h3>
            <form action="{{ route('signup') }}" method="post">
                <div class="form-group">
                    <label for="email">your E-mail</label>
                    <input class="form-control" type="text" name="email" id="email">
                </div>
                <div class="form-group">
                    <label for="first_name">First Name</label>
                    <input class="form-control" type="text" name="first_name" id="first_name">
                </div>
                <div class="form-group">
                    <label for="password">Password</label>
                    <input class="form-control" type="password" name="password" id="password">
                </div>
                <button type="submit" class="btn btn-primary">Submit</button>
                {{ csrf_field() }}
            </form>   
        </div> 
        <div class="col-md-6">
            <h3>Sign In</h3>
            <form action="#" method="post">
                <div class="form-group">
                    <label for="email">Your E-mail</label>
                    <input class="form-control" type="text" name="email" id="email">
                </div>
                <div class="form-group">
                    <label for="password">Password</label>
                    <input class="form-control" type="password" name="password" id="password">
                </div>
                <button type="submit" class="btn btn-primary">Submit</button>
            </form>
        </div>
   </div>
@endsection
1 like
harristars's avatar

@willvincent where exact place do i have to include the in my routes/web.php

 {{ csrf_field() }}

this is my web.php code

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/
//use class Session;

Route::get('/', function () {
    return view('welcome');
})->name('home');

Route::post('/signup', [
    'uses' => 'UserController@postSignUp',
    'as' => 'signup'
]);
harristars's avatar

@ habeebnet and @willvincent thanks guys the error gone God bless u.still i have another problem when i fill in the form for signup with the data and click on the submit button i get the following error.

ReflectionException in Container.php line 749: Class App\Http\Controllers\UserController does not exist


    in Container.php line 749
    at ReflectionClass->__construct('App\Http\Controllers\UserController') in Container.php line 749
    at Container->build('App\Http\Controllers\UserController', array()) in Container.php line 644
    at Container->make('App\Http\Controllers\UserController', array()) in Application.php line 709
    at Application->make('App\Http\Controllers\UserController') in Route.php line 203
    at Route->getController() in Route.php line 316
    at Route->controllerMiddleware() in Route.php line 278
    at Route->gatherMiddleware() in Router.php line 655
    at Router->gatherRouteMiddleware(object(Route)) in Router.php line 635
    at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
    at Router->dispatchToRoute(object(Request)) in Router.php line 596
    at Router->dispatch(object(Request)) in Kernel.php line 267
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
    at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
    at Pipeline->then(object(Closure)) in Kernel.php line 149
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
    at Kernel->handle(object(Request)) in index.php line 54

this is my app\Http\Controllers\UserController.php

<?php
namespace App\Http\Controllers;
//namespace routes;

use Illuminate\Http\Request;

class UserController extends Controller
{
    public fuction postSignUp(Request $request)
    {
        $email=$request['email'];
        $first_name=$request['first_name'];
        $password=bcrypt($request['password']);

        $User=new User();
        $User->email=$email;
        $User->first_name=$first_name;
        $User->password=$password;

        $User->save();

        return redirect()->back();


    }
    public fuction postSignIn(Request $request)
    {

    }
}
yudhi_casanova's avatar

just repair in this syntacs like my code

@if(Session::has('message')) {{ Session::get('message') }} @endif

'Session', not 'session'

Please or to participate in this conversation.