Laravel永远不会忘记会议中的一个项目


Laravel never forget an item from session

我将一个数组推入Laravel会话:

  "accountConfirm" => array:1 [
    0 => array:2 [
      "table" => "teacher"
      "id" => 37
    ]
  ]

当我调用Session::flush()Session::forget('accountConfirm')时,在下一行进行测试

if ( Session::has('accountConfirm') ) 
{
  // false
}

但是之后,没有remove函数(flush, forget),当我做同样的测试时:

if ( Session::has('accountConfirm') ) 
{
  // true
}

为了确保这件事我不会再推了。

为什么会发生这种情况?

复制并传递到路由中,然后导航到每个url查看结果。

Route::get('/session/set',function(){
  Session::put('name','John');
  if (Session::has('name')){
    echo Session::get('name');
  }
});
Route::get('/session/forget/',function(){
  Session::forget('name');
  if (Session::has('name')){
    echo Session::get('name');
  }else{
    echo 'Name is not set';
  }
});