重定向laravel 5.4后验证会话数据刷新

时间:2017-07-03 07:20:59

标签: session authentication laravel-5.4

我正在使用laravel 5.4和使用auth的登录用户

SELECT DISTINCT x.* 
           FROM my_table x 
           JOIN my_table y 
             ON y.id <> x.id 
            AND y.item = x.item 
            AND DATEDIFF(GREATEST(y.sale_date,x.sale_date),LEAST(y.sale_date,x.sale_date)) < 365;

正如您在$.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); $.ajax({ type: "POST", url: "./post_xing_res", data: {user_data:response}, success: function(msg){ console.log(msg); if(msg == 1) { location.href='http://192.168.1.12/maulik_proj/studicash_new/public/welcome'; } } }); } 中看到的我的ajax调用,我正在使用auth,如下所示 $ created_at = $的updated_at =时间();

/ if(Request :: ajax()){ /

post_xing_res

正如您所看到的,当打印 $data = Input::all(); $check_acc_first = DB::table('users') ->where('login_with',3) ->where('xing_id',$data['user_data']['user']['id']) ->first(); if ($check_acc_first) { Auth::loginUsingId($check_acc_first->user_id); echo "<pre>";print_r(Auth::user()); } else { $insert_user = DB::table('users')->insertGetId( array('login_with' => 3, 'xing_id' => $data['user_data']['user']['id'], 'profile_pic' => $data['user_data']['user']['photo_urls']['maxi_thumb'],'first_name' => $data['user_data']['user']['first_name'],'last_name' => $data['user_data']['user']['last_name'],'email' => $data['user_data']['user']['active_email'],'created_at'=>$created_at,'updated_at'=>$updated_at) ); $user_data = DB::table('users') ->where('user_id',$insert_user) ->get(); //echo "<pre>";print_r($user_data); Auth::loginUsingId($user_data->user_id); } if (Auth::check()) { echo 1; exit; } 并获得1作为响应时,我能够获取用户数据以及Auth :: user数据 但是,当我重定向到欢迎页面Auth::user时,数据会返回空白 以下是我的路线文件

Auth::user

你能帮我解决这个问题 提前致谢

0 个答案:

没有答案