mercredi 31 août 2016

Laravel 5.2 Routing Session

My routes look like this:

Route::put('session/userinfo', function (Request $request) {
  $request->session()->put('userinfo', 'value');
});
Route::get('session/userinfo', function(Request $request) {
  return $request->session()->get('userinfo');
});

I've also tried this:

Route::put('session/userinfo', function () {
  session('userinfo', 'value');
});
Route::get('session/userinfo', function() {
  return session('userinfo');
});

and this:

Route::put('session/userinfo', function () {
  Session::put('userinfo', 'value');
  Session::save();
});
Route::get('session/userinfo', function() {
  return Session::get('userinfo');
});

None of these throws any errors, but I never receive any session info. I do have Route::group(array('middleware' => ['web', 'auth']) and also tried 'middlewareGroups' instead of 'middleware'. Nothing changes. Wtf do I have to do to utilize Session?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire