Support the ongoing development of Laravel.io →
Configuration Session
Last updated 2 years ago.
0

Reflash a flash session from one controller to another? What exactly do you mean by that?

Last updated 2 years ago.
0

I land on / (homeController.php) and I do Session::flash('test', 123);

I then go to /search (searchController.php) and I do Session::all() and I no longer see 'test'. The flash data should persist for one request and yet it does not. Why is this?

Last updated 2 years ago.
0

It works for me. Make sure you're not doing redirects somewhere, I think a redirect might count as a request.

Last updated 2 years ago.
0

It would normally not behave like that. Can you show us some code?

Also, are other sessions working correctly?

Last updated 2 years ago.
0

There is no redirects elsewhere. Other sessions (using Session::put) are behaving correctly.

Some code for you:

HomeController.php


<?php

class HomeController {

    public function __construct()
    {
        Session::flash('test', '123');
    }

	public function showHome()
	{
        var_dump(Session::all());
    }

}

SearchController.php


<?php

class SearchController {

    public function __construct()
    {
    }

	public function showIndex()
	{
        var_dump(Session::all());
    }

}

After var_dump-ing Session::all(), no flash session vars show up

Last updated 2 years ago.
0

You cannot have any output before setting a session variable. I believe the var_dump is interfering with your session setting. Try return a Response object in the controller action instead

Last updated 2 years ago.
0

I removed var_dump and it seems that the first flash works. Then I added reflash in SearchController.php, it still doesnt seem like reflash is working for me when I refresh the page.

Last updated 2 years ago.
0

I think you must paste a line like this session_start() at the begin of function or program for example

<?php
session_start();
class HomeController {

   public function __construct()
   {
       Session::flash('test', '123');
  }

  public function showHome()
  {
        var_dump(Session::all());
  }
}
?>
Last updated 2 years ago.
0

Tried that and still that same /: Any other suggestions? Thank you for any help so far.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

apburks apburks Joined 6 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.