41821

Laravel Session store not set on request

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

Answer1:

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!

Answer2:

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 () {

Answer3:

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

Answer4:

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

Recommend

  • Zend Framework 2 - get the new filename when uploading using a validator for inputfilter
  • How to get rid of laravel_session cookie from Laravel Application ?
  • Get $_POST from PHP to Javascript and pass it to another php
  • TokenMisMatchException in Laravel 5.4
  • Route::controllers - Method [index] does not exist on [App\\Http\\Controllers
  • PHP anonymous function variable as reference
  • How to apply a partial derivative Gaussian kernel to an image with OpenCV?
  • What do getresuid() and setresuid() do?
  • Mocking Non-Standard Events in F# Foq
  • Configuring Ninject
  • How do I change the kernel/python version for iPython?
  • Relative paths. baseUrl and paths not working on ionic2 - angular2
  • Efficient & Pythonic way of finding all possible sublists of a list in given range and the minim
  • triggering user space with kernel
  • How to open html table in xls on click of a button
  • Laravel 4 routing not working due to .htaccess file?
  • Django Haystack Rebuild Index
  • Exception creating JSON with LINQ
  • Use tryCatch within R loop
  • Exception gevent.hub.LoopExit: LoopExit('This operation would block forever',)
  • converter json to two dimensional array
  • cordova is not defined - cordova.js has already been loaded :: Ionic
  • Azure webjobs output logs indexing taking very long
  • Updating both a ConcurrentHashMap and an AtomicInteger safely
  • Python pickle not one-to-one: different pickles give same object
  • JqueryMobile Popup menu is not working
  • Breaking out column by groups in Pandas
  • Not able to aggregate on nested fields in elasticsearch
  • How do I alternate colors in Flat List (React Native)
  • $wpdb not working in file of WordPress plugin
  • Meteor helpers not available in Angular template
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Read text file and split every line in MSBuild
  • C# - Serializing and deserializing static member
  • Java applet as stand-alone Windows application?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Proper way to use connect-multiparty with express.js?
  • Error creating VM instance in Google Compute Engine
  • Conditional In-Line CSS for IE and Others?