I 'm trying to create a variable that will last me a very short time , since the switch to another page and then give the option of returning the variable browser maintains its value, how can I avoid this? what I need is that the variable disappears.
Flash Data
Sometimes you may wish to store items in the session only for the next request. You may do so using the flash method. Data stored in the session using this method will only be available during the subsequent HTTP request, and then will be deleted. Flash data is primarily useful for short-lived status messages:
$request->session()->flash('status', 'Task was successful!');
If you need to keep your flash data around for even more requests, you may use the reflash method, which will keep all of the flash data around for an additional request. If you only need to keep specific flash data around, you may use the keep method:
$request->session()->reflash();
$request->session()->keep(['username', 'email']);
The problem is that the back button does not make a request petition , for this reason does not work, with a refresh perfecetamente works , also thanks .
I didn't catch exactly what you're trying to do, but have you already checked Laracasts' flash package on GitHub? https://github.com/laracasts/flash
Maybe it's useful for you, in this case. Remember that flash, as jlrdw said, will store the data for a next request. Maybe I can help you better if you give me more details.