我在 laravel 中实现了一个带有 flywire 的支付网关。我有一个方法可以毫无问题地将数据更新到 crm,当被调用到另一个重定向到外部 url 的方法时我需要这个数据(是一个向导)问题是在重定向之后会话的值是丢失的。重定向到外部 url 后如何保存这些值?
use Session;
public function update(Request $request)
{
//code..
Session::put('value1',$request->val1);
Session::put('value2',$request->val2);
$url = 'https://www.urldemo.payment.com/payment/';
$data=[
'value1'= $request->val1,
'value2' = $request->val2,
];
$params = json_encode($data);
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,$params);
try{
$response = curl_exec($curl);
$info = curl_getinfo($curl);
$err = curl_error($curl);
curl_close($curl);
return response()->json(['success'=>'the update was completed success','url'=> $url],200);
}catch(Exception $e){
return response()->json(['errors'=> $e->getMessage()],422);
}
}
/*This function retrieve the response data from the payment update*/
public function returnData(Request $request){
$obj = json_decode($request->getContent());
if(Session::exists('value1')){
$p1 = $obj->id;
}elseif(Session::exists('value2')){
$p2 = $obj->id;
}else{
$p1 = '';
$p2 = '';
}
$data2 = [
'value1' => $p1,
'value2' => $p2,
];
$values = json_encode($data2);
dd($values);
/*Here print the $p1 and $p2 empty thats after redirect to a external url the point is that here the session is lost*/
}
我现在的问题是如何在 Laravel 5.5 中重定向后保持会话?