use Illuminate\Support\Facades\DB;
use App\Student;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Session;
use Illuminate\Contracts\Routing\ResponseFactory;
class Student1Controller extends Controller{
public function session3(Request $request){
return Session::get('mess','暂无信息');
//return 'session3';
//return 'session';
}
public function response(){
//return redirect('session3');
return redirect('session3')->with('mess','我是快闪数据');
}
}
为什么第一次访问就是暂无信息呢??
哈哈,解决了,在路由配置中,把response的路由放到中间件里面
Route::group(['middleware' => ['web']],function() {
Route::any('session1',['uses'=>'studentController@session1']);
Route::any('session2',['uses'=>'studentController@session2']);
//controller之response
Route::any('response',['uses'=>'studentController@response']);
});
解决了吗,我的也是这样
配置过 了
路由里有配置response这个允许加载session吗 就是和你的session3那个一样的位置