[Proposal] Redirect::with option to store in permanent session rather than flash
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.
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.
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);