Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取在laravel 5.3中的ajax调用期间已经设置的会话变量?_Php_Jquery_Ajax_Laravel - Fatal编程技术网

Php 如何获取在laravel 5.3中的ajax调用期间已经设置的会话变量?

Php 如何获取在laravel 5.3中的ajax调用期间已经设置的会话变量?,php,jquery,ajax,laravel,Php,Jquery,Ajax,Laravel,//这是设置会话变量calles sport_id的ajax调用 public function searchAthlete(Request $request) { if($request->ajax()){ $id = $request->id; Session::put('sport_id',$id); return response()->json(Session::get('

//这是设置会话变量calles sport_id的ajax调用

public function searchAthlete(Request $request)
    {
        if($request->ajax()){
            $id = $request->id;
            Session::put('sport_id',$id);
            return response()->json(Session::get('sport_id'));
        }
    }

为什么不使用json()发送
['id'=>$id]
?谢谢,我会尝试一下。实际上,我想在ajax调用期间设置会话,以便以后使用。我只是在ajax调用期间检查是否可以实际设置会话,然后返回session::get('sport_id')以验证会话是否已设置。然后在json()中执行类似于
['id'=>session::get('sport_id')]
的操作