I have a delete link to delete a Comment object by ID /comment/:id/delete
To protect this link, I add the csrf token to the link
$CSRFTokenForm = new BaseForm(); $link = url_for(..., array('_csrf_token' => $CSRFTokenForm->getCSRFToken()));
and in executeDelete I use the checkCSRFProtection() method and everything works fine.
The only thing is that each comment appears partial, and each partial creates its own BaseForm() to create a token, which is a waste of time, since they are all the same.
Do you have a better idea on how to make it more efficient, for example, using the static getCSRFToken() method or creating a global BaseForm() ?
source share