vixa
vixa

Reputation: 33

How to pass hidden parameters when redirecting a route ? (With POST ?)

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 ?

Upvotes: 1

Views: 1639

Answers (2)

Etshy
Etshy

Reputation: 880

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.

Upvotes: 0

Yassine CHABLI
Yassine CHABLI

Reputation: 3724

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

Upvotes: 1

Related Questions