I can't seem to find a way to set $_POST to an empty array.

I have a form in phtml action to self I can get $_POST values the following ways:



The Above will give Array ( [form_key] => FThdknnc_347djcncKey_)

Now I've tried to reset by doing:


But it gives me:

Array ([form_key] =>)

That ain't right browser still popping up saying that it will resend data from form: It should return Array () But the form_key key is still in the $_POST Array. one can do in php:

$_POST = Array(); and that would be enough but it doesn't work with magento.

Anyone any idea?


Try this:

/** @var \Zend\Stdlib\ParametersInterface $postParameters */
$postParameters = $this->getRequest()->getPost();

Use getQuery method to clean GET parameters.


You can try like this,

$formKey = $this->getRequest()->getPostValue('form_key');


than after you can try to set again


Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.