3

I'm developing a small website and have problems with the session. When I try to login or make an AJAX call, I get the following RuntimeException:

RuntimeException in Request.php line 758: Session store not set on request.

in Request.php line 758
at Request->session() in VerifyCsrfToken.php line 87
at VerifyCsrfToken->tokensMatch(object(Request)) in VerifyCsrfToken.php line 49
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Language.php line 38
at Language->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Language), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54

Any idea what have I done wrong. Thanks in advance

icemanblas
  • 93
  • 1
  • 1
  • 10

4 Answers4

1

Look at @Cas Bloem his answer here this helped me out amazingly:

Laravel - Session store not set on request

That's why it wasn't working for me. Cause you're using a session that is expection matching CSRF tokens (is my best guess, I'm new to Laravel myself).

Also if you go to app->http->middleware->VerifyCsrfToken this is were you can add routes to the array that won't be checked for CSRF verification. This plus Cas Bloem his fix (place routes in different section in routes.php) fixed my problem. I'm just developing/learning on localhost right now but need to implement this later on.

Hope this helps/clears thing up!

Community
  • 1
  • 1
Kasper
  • 11
  • 3
1

Assuming you use Laravel 5.2: You'll need to use the web middleware if you need session state, CSRF protection, and more. (like the global in 5.1)

Route::group(['middleware' => ['web']], function () {

ain
  • 11
  • 1
  • 1
    The OP states he uses 5.1 – Uwe Allner Feb 15 '16 at 09:00
  • Yes, I used 5.1 on that project, and as I said earlier, the solution was to create a fresh copy of Laravel 5.1 and import all files that I generated. That project was a mess, several developers worked on it, and I managed to handle it. Thanks for the help, but this was one of a kind experience, so no correct answer can be selected, although your answers may work for other issues related to this exception. – icemanblas Feb 16 '16 at 09:19
0

delete everyting inside this folder storage/framework/sessions and make sure this folder has write permission

Milan Maharjan
  • 4,156
  • 1
  • 21
  • 28
0

Does the file '/config/session.php' exist in your project? If not, create it and make sure all the options are set correctly.

markashworth
  • 1,141
  • 10
  • 17
  • 2
    Yes, it does exist, and to my knowledge, all the options are set correctly. I will double check and see if there is something I can do. Still, I had to create a new project and manually import all my files, and now the other project works as expected. – icemanblas Nov 08 '15 at 17:32