2

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 2

5

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

Sign up to request clarification or add additional context in comments.

Comments

0

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');
    

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.