We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

I have problem with security token

I have this in HTML

<input type="hidden" name="<?php echo $this->security->getTokenKey(); ?>" value="<?php echo $this->security->getToken(); ?>"/>

and this in PHP

if ($this->security->checkToken()):

then when I click again to see if it works the token it says the token does not work

why? help me



4.7k

What do you mean with "then when I click again to see if it works..."? Each token is only valid for one request. If you fired the request and try to reload the Page with F5, the token will be invalid.

Thats the main reason for the Security Token. It prevents your forms to be fired from anywhere. It only allows the form to be fired from within your application and each request only one time.