I am new in laravel. I have two controllers with functions 1> CartController@finalizeCart and 2> PaymentController@postPayment. Now, I want to pass the variable TotalPrice from <1> to <2>. My question is: how can I pass value from one controller to another one directly?
2 Answers
You can do this in the first controller
Session::put('key', 'value');
Then in the second
Session::get('key');
More info can be found in the documentation here http://laravel.com/docs/5.0/session#session-usage
Comments
There is another way to pass data from one controller to another that is passing data by cookies
Your first controller:
$response = Response::make('Hello World'); return $response->withCookie(Cookie::make('name', 'value', $minutes));And get it in the next request
$value = Cookie::get('name');