Once in my login I set values of user to session like this..
session()->set("user", $user);
And for get the values of the session from anywhere in my application attach with it to $request
$request->_user = $user;
like this. So I can get it like this from anywhere
$user = $request->_user;
Thing is I want pass some ID of purchase order at the midle of the application. So can I attach it to existing session or how to create new session and append the ID. With that ID, page redirect to paypal and If user cancel the payment I can catch his canceled payment with that ID. That is why I thought session would help me. After a successful payment it is OK to destroy that session. Help me !!!
You can continue to append data to the session while the user is using your application. Assuming you want to store a array of purchase IDs, you can do:
This will create an array so you can later save all the IDs that the user attempted to purchase:
This will return an array with all the
item_ids
you've pushed to the array:After successful purchase or after you've saved the canceled purchase details, just start a new session or delete the item_ids.