I need to receive value from a redirect with with in controller

Asked

Viewed 31 times

0

In my class loginController I make the following way:

return Redirect::to('home')->cookie($nome)->cookie($sessionid)->with('cnpj',$cnpj);

I need to have that data $cnpj to pass on the home.blade.php for cliente.blade.php

How do I do this? At home there is no form. Only I don’t want to pass with cookie. Actually I don’t want to pass any as cookie.

1 answer

0

Actually when you use the Redirect::to('home')->with(variavel) this variable can already be accessed in your other method(home). To access inevitable you have to use a session. You can take the value of the CNPJ from this method: Session::get('data');

You have to remember that the redirect in PHP reloads the page, making a request, generating a new PHP execution. That’s why the memory of variables from before is no longer accessible.

From your code posted I imagine you are using an old version of Laravel, I recommend reading the framework documentation:

https://laravel.com/docs/4.2/responses

Browser other questions tagged

You are not signed in. Login or sign up in order to post.