I am trying to store booking details with the help of a session variable. In the first function:
public function hold(Request $request){
$details = [
'times' => $arr,
'subTotal' => $subTotal,
'tax' => $tax
];
$request->session()->forget('cart');
$request->session()->put('cart',$details);
}
Next, it will be posted to another function of same controller. Upto this point session is available.
public function checkout(){
dd(session()->all());
}
Next route is on payment controller. This is another controller than the previous one. Here, the session variable is empty.
public function createPayment(){
dd(session()->all());
}
What am I doing wrong? How can I access session in this createPayment function?
put default array
$request->session()->put($details);
After looking Ohgodwhy
comment I recheck my route then I realize I had previously completed this payment module through api. So, my mistake was to route to api instead of web. Hence, there is no way to retrieve session variable to API route.
I was using API and web routes so session variable were not available across.