会话值未显示在刀片页面上
adminController
use Session;
Session::put('adminusername', "test");
echo Session::get('adminusername'); //it prints here fine
mater.blade.php
Welcome:{!! Session::get('adminusername') !!}
答案 0 :(得分:0)
需要在中间件中定义路由
Route::group(['middleware' => ['web']], function () {
Route::group(array('prefix'=>'admin'),function(){
Route::get('login', 'admin\AdminHomeController@showLogin');
Route::post('check', 'admin\AdminHomeController@login_check');
Route::get('dashboard', 'admin\AdminHomeController@showDashboard');
}
答案 1 :(得分:0)
use Session;
public function showsession()
{
Session::put('adminusername', 'test');
return View::make("folder/page.php")->with('adminusername',Session::get('adminusername'););
}
查看
Welcome:{!! $adminusername !!}
答案 2 :(得分:0)
将此中间件放在kernel.php中
protected $middlewareGroups = [
'web' => [
.....other classes
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
......other classes
],
'api' => [
'throttle:60,1',
],
];