framework icon indicating copy to clipboard operation
framework copied to clipboard

[Proposal] Redirect::with option to store in permanent session rather than flash

Open alexdover opened this issue 12 years ago • 2 comments

I want to redirect to another page and pass a couple of parameters over, the redirect with method is perfect for this, but I notice that by default this variable goes into the flash storage, so as soon as I get it on the next page it is then gone from the session, whereas I was hoping to use it a few times.

It might be useful to add a third parameter to the with method, called $permanent or similar which then call $session->put rather than $session->flash

It is easy enough for me to do

Session::put('my_variable', $my_variable);
Redirect::to('my_new_url');

but I thought

Redirect::to('my_new_url')->with('my_variable', $my_variable, true);

might be more elegant

If considered useful then I am happy to submit a pull request with the change to the RedirectResponse.

alexdover avatar Dec 13 '13 12:12 alexdover

The true does not tell anything about what is going on, whereas with your first example this is not a problem. Laravel is all about expressiveness, so boolean parameters are considered evil.

JoostK avatar Dec 13 '13 16:12 JoostK

Good point. You are right, the boolean flag is not a very good indicator of what is going on.

I guess that means either the first option of setting the session variable before the redirect is considered acceptable, in which case I will close this proposal, or another method is added which is more descriptive, for example

Redirect::to('my_new_url')->withandkeep('my_variable', $my_variable);

or maybe

Redirect::to('my_new_url')->withandput('my_variable', $my_variable);

alexdover avatar Dec 18 '13 14:12 alexdover