Alvaro
Alvaro

Reputation: 41605

Avoid black-holed request after back button CakePHP2.2

I have noticed the form is black-holed when I use Security Component at CakePHP2.2 and a user clicks on the back browser button to return to a form after having clicked on other link of the site.

For example:

home

click on new post link (but not posting)

click on news

back to new post

Trying to post ---> BLACK-HOLED!!

Is there any way to avoid this?

Thanks.

Upvotes: 2

Views: 953

Answers (2)

Ondrej Henek
Ondrej Henek

Reputation: 904

Actually there is a way. You can disable browser caching for the page with form so when you hit the back button, whole new page is loaded from server with new hashes.

$this->response->disableCache();

just put it into your Controller method.

Upvotes: 5

floriank
floriank

Reputation: 25698

No you can't because the idea is to avoid form manipulation. Each form gets a unique hash generated when it is rendered the first time. This hash is checked server side when the form is submitted. The 2nd time you try to submit the form when you hit the submit button the hash is not longer valid. You can disable the post security check for that action but I would not sacrifice security for that.

Upvotes: 2

Related Questions