1

When I do a redirectToRoute, I want to pass hidden parameters. Pass the parameter in a route does not satisfating me, because I want the information hidden. I was thinking to do that with POST, but I don't know how to pass POST parameters in the redirectToRoute function. Can I do that ?

1
  • No parameters for a redirect. And the next time you have a browser running, press F12 then click on the network tab. Then ask yourself how exactly can you hide information from even a slightly knowledgeable user. Commented Apr 2, 2019 at 22:31

2 Answers 2

2

You can't redirect a POST request because the browser would have to resend the POST data , so you have to use forward like:

return $this->redirectToRoute('name_of_route_to_redirect', ['max' => 10,...]); 

For more information , take a see in the documentation symfony controller

You can send the Request object inside :

return $this->redirectToRoute('route', [ 'request' => $request ], 307); 

that 307 guarantees that the method and the body will not be changed when the redirected request is made

Sign up to request clarification or add additional context in comments.

Comments

0

What you could do is storing your parameters in some file/memory cache.

You redirect without parameters and on your action you check if you have some parameters in the file/memory cache and get them from there.

I don't know if it's a good thing to do though, but it seems possible to do.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.