That's not much info to go on.
Other session storing/retrieving methods working fine? Anything in the log file? What session driver are you using? Write permission set correctly on storage folder?
Sorry for being so broad, for starters...
Other session storing/retrieving mechanisms work fine. As a matter of fact I'm using, as a temporary workaround, Session::put
(and Session::forget
afterwards) to display flash data on the remote server.
Nothing unusual shows in the log file.
I'm using a "file" session driver and have ensured the storage folder is set to the proper permissions. I have also tried with the cookie driver — it works properly but doesn't solve the issue.
A var_dump()
or dd()
of Session::all()
on the remote server will display its content, but unfortunately no data is stored in neither the old
and new
members of its flash
array.
Other session storing/retrieving methods working fine? Anything in the log file? What session driver are you using?
asad
So, if you literally do this in your controller:
Session::flash('message', 'test');
dd(Session::all());
you get empty flash.old
and flash.new
arrays?
Could you try this in your php artisan tinker
console:
Session::flash('message', 'test');
var_dump( Session::all() );
First of all thanks for your help Xum.
Session::flash('message', 'test');
var_dump( Session::all() );
...works as expected in the tinker
console (i.e. dump shows the flash.new
array is populated with message => test
).
The literal...
Session::flash('message', 'test');
dd(Session::all());
...in the controller dumps the expected result as well.
Then Session::flash('message', 'test')
—no direct dump afterwards— will display the expected result in a view rendered with View::make()
from a controller.
But the culprit seems to be Redirect
.
On any controller methods ending with a Redirect::back
, Redirect::to
or Redirect::route
, if I var_dump(Session::all())
when I reach the view, both flash.new
and flash.old
will be empty...
I already did, to no avail.
:(
It actually is the basis of my code and it's working fine in homestead
.
Hm... the fact that flash.old
is empty makes me think that session saving (during which old
flash data is discarded, and new
is moved to old
) happens twice between requests.
I have a few crazy ideas that you could try, but frankly I'm poking in the dark here.
The most sane I have is to try database
driver for sessions, to rule out peculiarities of Heroku's file system as the reason.
The most sane I have is to try
database
driver for sessions, to rule out peculiarities of Heroku's file system as the reason.
Thank very much, it's very insightful... Honestly I was running out of things to try. So I'll give it a shot and keep ruling out things in this direction.
If I ever find the proper answer I'll post it here in case it could help others out. Again, thanks a bunch for your help!
Hmm... unfortunately this is not working either. I can testify the database driver-backed session is working properly, but still no flash data.
I'll use my workaround for now...
Xum said:
Hm... the fact that
flash.old
is empty makes me think that session saving (during whichold
flash data is discarded, andnew
is moved toold
) happens twice between requests.
There! Thanks a million Xum.
I had a before
filter app-wide that would only be triggered in the prod env, and it would end up misfiring an undesired redirect
. The flash data would be lost at that point!
Check your session config to ensure you have the right domain:
<?php return array( 'domain' => 'yoursite.com', 'cookie' => 'yoursite', );Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community