ssquare
119
3
Laravel

Session Variable disappeared in controller

Posted 1 month ago by ssquare

I am trying to store booking details using 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?

Please sign in or create an account to participate in this conversation.