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

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?

0

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.

Last updated 9 years ago.
0

Other session storing/retrieving methods working fine? Anything in the log file? What session driver are you using?


asad

0

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() );
0

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...

Last updated 9 years ago.
0

Try this:

Redirect::to('some/where')->with('message', 'test');
0

I already did, to no avail.

:(

It actually is the basis of my code and it's working fine in homestead.

Last updated 9 years ago.
0
Solution

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.

0

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!

0

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...

0

Xum said:

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.

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!

0

Check your session config to ensure you have the right domain:

<?php return array( 'domain' => 'yoursite.com', 'cookie' => 'yoursite', );
0

Sign in to participate in this thread!

Eventy

Your banner here too?

dheavy dheavy Joined 10 May 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.