Home > database >  Delete/modify GET (querystrings) parameters in Symfony controller at refresh page
Delete/modify GET (querystrings) parameters in Symfony controller at refresh page

Time:11-19

I'm attempting to remove the querystrings paramateres displayed in the browser url:

https://foo.bar?key=value

Is it possible to modify GET (querystrings) parameters at refresh in Symfony controller without redirection? For example:

public function testAction(Request $request): Response
{
    $request->query->get('test'); //output: querystring parameter named test

    //some way to change the GET parameters

    return new Response();
}

How to remove 'test' parameter on refresh? Obviously, I can remove the parameter from a request, but it doesn't affect the response. I believe problem is that don't have a deep understanding of how is request passed to response in Symfony.

CodePudding user response:

You can modify query string (GET parameters) two ways:

  1. Using JavaScript (How can I remove the query string from the url after the page loads?)
  2. By redirection
  • Related