您好我正在尝试将值存储在laravel中的会话中。我想存储一个值以获取设置的最后一个值。
我有这条路
web.php
Route::prefix('v1')->group(function () {
Route::get('/{lol}', 'MyController@test');
});
myController的
public function test($lol){
if($lol == "lol" ){
session(['lol' => $lol]);
}
dd(session()->get('lol'));
}
http://localhost/laravel/v1/lol =>返回值!好!
http://localhost/laravel/v1/123 =>返回null!,为什么???
我想返回大声笑,因为我需要存储在会话中的最后一个值。
我想php中的$ _SESSION可以很好地用于此目的。
但是在Laravel我不能用它。