【问题标题】:How to determine session value at Controller [closed]如何在控制器上确定会话值 [关闭]
【发布时间】:2021-09-20 10:55:06
【问题描述】:

我在 Blade 上设置了这样的会话值:

@php
if(...){
    Session::put('sent','city')
}else{
    Session::put('sent','country')
}
@endphp

现在,我需要在 Controller 上检查 sent 会话值,但不知道如何...

如果你知道,请帮帮我。

谢谢。

【问题讨论】:

标签: php laravel session laravel-8 laravel-session


【解决方案1】:

与插入值相同 (documentation):

public class SomeController{
  public function some_method(){
    $value = session()->get('sent');
    // or if you are not certain that the value is being set
    $value = session()->get('sent', 'default_value');
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-07
    • 2011-05-01
    • 1970-01-01
    • 2013-12-08
    • 1970-01-01
    • 2011-10-13
    • 2016-08-24
    • 1970-01-01
    相关资源
    最近更新 更多