Leaving this here for anyone else who could need it:
Session::start(); after setting the session id worked. D'oh! :)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm stumped on something.
I have a checkout process where a user enters billing info and selects a product, both of which are stored to the session (not written to the DB). One of my payment methods is Affirm, which generates a checkout link that I forward the user to, and on success, affirm sends a post request to my callback route. Problem is, on that callback route I can't restore the session to finalize the transaction (e.g. write the model to the DB and fire events).
I can send metadata along with the payload of the payment processor to return to my callback, so I put the session id in there, but on the callback method I can't hydrate the session from that id. I have the user id but logging in with that just generats a new session key and I lose my billing data and model in the session.
// user is logged in and adding trip to cart
public function addToCart(Request $request, Trip $trip)
{
session()->put('cart_trip', $trip);
return view('some-view-here');
}
Upon checkout, I redirect them to Affirm's application. Upon success, they send a post request to me with a given payload. In this instance, I added the session key.
// post request handler.
public function affirmSuccessCallback(Request $request)
{
$charge = Payment::authorizeAffirm($request->input('checkout_token'));
session()->setId($charge['details']['metadata']['session_id']);
// this is null
dd(session('cart_trip'));
// can't do this either since it'll just make a new session
Auth::login($charge['details']['metadata']['session_id']);
}
I need a way to restore that session to access the model and billing data that was filled out during the checkout process on my site before going to Affirm.. ideas?
Leaving this here for anyone else who could need it:
Session::start(); after setting the session id worked. D'oh! :)
Please or to participate in this conversation.