thmspl thmspl - 1 year ago 117
PHP Question

Laravel Redirect->with(key, val) not working

I would like to send Informations from one function to an another with the

->with(key, val)
function, but it doesn't work. I've tried soo many things but it doesn't work.

Here my actual setup (I'm using laravel 5.2):


Route::group(['middleware' => ['web']], function() {
Route::get("/test1", "InfoController@test1");
Route::get("/test2", "InfoController@test2");


class InfoController extends Controller
public function test1(){
return View::make("infos");

public function test2(){
return Redirect::to("/test1")->with("hello", "world");



The sit empty -> no output.

Where is the problem?

Answer Source

with() passes session data, not a variable. So you need to use session get() method to get the data:

{{ Session::get('hello') }}

Also, if you're using 5.2.27 or higher, remove web middleware to make sessions work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download