PHP Laravel:如何设置或获取会话数据?
我想在会话中存储一些数据以用于某些测试目的。我也在控制器中编写了会话代码。但是在控制台.log ->资源 ->会话中,我找不到任何我存储的值。如果有人帮助我找到我在控制器中犯的错误,请。
这是我的控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Department;
use App\Http\Requests;
use Cookie;
use Tracker;
use Session;
public function postdepartmentSave(Request $request)
{
$this->validate($request,[
'code' => 'required|min:2|max:7|unique:departments',
'name' => 'required|unique:departments',
]);
$department = new Department();
$department->code = $request->Input(['code']);
$department->name = $request->Input(['name']);
$name= $department->name;
Session::put('name', $name);
dd($name);
$department->save();
return redirect('departmentSavePage');
}