In laravel 5.7, session is getting disappeared after redirecting to another page. I am working on an application in which I am pushing users to the payment gateway page before which I am storing the data in a session as per laravel documentation. After coming back from the payment gateway when I try to retrieve that session it returns empty. Can anyone please tell me how can I resolve this issue.
My code is something like this
public function processPayment(Request $request)
{
//...........
session()->put('order_checkout_data', [
'gateway' => 'paypal',
'data' => $paypalData
]);
//$request->session()->save(); <!-- This i tried after reading some solution but didnt help
//print_r(session('order_checkout_data')) <!-- I can see the session here
$paypal = new PayPal();
$response = $paypal->purchase($paypalData);
if ($response->isRedirect()) {
$response->redirect(); //This is where redireting to paypal
}
}
public function handleGatewayResponse(Request $request){
print_r(session('order_checkout_data')); //No data
}
I tried with session global function and facade as well , like these
Session::put('order_checkout_data', [
'gateway' => 'paypal',
'data' => $paypalData
])
and also
session(['order_checkout_data'=>[
'gateway' => 'paypal',
'data' => $paypalData
]])
But no value. My env settings likes this
SESSION_DRIVER=file
SESSION_LIFETIME=360
I tried to go through some of the links with a similar problem but that didn't help. Here are the links that I have followed :
- Laravel 5 session not persisting after user is logged in
- https://laracasts.com/discuss/channels/laravel/session-is-not-persisting-on-server?page=1
- Laravel session data get cleared out after redirect to next page
- PHP session lost after redirect
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire