Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JCKN123's avatar

Laravel Session not working in production server

Hello All,

For some reason laravel session not working in production server, it works fine at local server.

""

0 likes
12 replies
JCKN123's avatar

" public function store(Request $request) { $input = request()->all(); $params = array(

            'paymentDetails' => array(array(
               
                'expirationMonth' => session()->get('ccmonth'),
                'expirationYear' => session()->get('ccyear'),
                'billingAddress' => array(
                    'address1' => null,
                    'address2' => null,
                    'country' => 'US',
                    'city' => $input['city'],
                    'state' => 'CT',
                    'zipCode' => $input['zipcode'],
                ),
                'amountToCharge' => session()->get('prepaidcardtotal'),
              
             
            )
            ),

        );

}

public function getPaymentGatewayResponse(Request $request) {

    $input = request()->input();

// dd($input); $expirationdate = explode("-",$input['req_card_expiry_date']); $month = $expirationdate[0]; $year = $expirationdate[1]; $lastfour = substr($input['payment_token'], -4);

    session()->put('last_four', $year);
    session()->put('ccmonth', $month);
    session()->put('ccyear', $lastfour);
    session()->save();

return view('elements.blocks.iframe2', ['response' => $input]); }

"

This works fine at local server but not iin production sever, can some one can help me around this.

tykus's avatar

How is your Session driver configured on the production server?

tykus's avatar

Are you in a single server environment; is every request handled by the same server?

JCKN123's avatar

Yes it’s a single server environment. I got response back from cybersource payment. Using sessions I was passing transaction I’d, month , year to checkout page above.

It’s working in local. But not in production. It’s showing null

Snapey's avatar

Are you expecting a webhook from the payment processor to match up with the same session?

tykus's avatar

Didn't see the webhook angle, but wouldn't explain the issue with local vs production; unless OP was spoofing the payment process response

JCKN123's avatar

I’m not sure if I can understand the question..

New to laravel...

I want to pass the data in between the functions in a same controller using sessions.

I will get the response from cybersource acceptance to getpaymentgatewayresponse() function

tykus's avatar

Is the CyberSource "response" a separate request into your application; or is it the response of a cUrl/Guzzle request you are making?

JCKN123's avatar

I’m not making any request to the cybersource. I provided post back url to get back response from cybersource.

Thanks

Snapey's avatar
Snapey
Best Answer
Level 122

so when they postback, that request has nothing to link it to the session data

JCKN123's avatar

Yes its nothing to link it to session data,

Please or to participate in this conversation.