2

I need to delete the CRAFT_CSRF_TOKEN cookie when a form submission reaches certain/success page. I'm using CSRF stripped cookie's value to store entry title like this:

{% set token = craft.request.csrfToken[:10]|replace({'~':'P', '_':'B', '|':'T'})|upper %}

Upon succesful form submission I'd like to erase cookie name CRAFT_CSRF_TOKEN and it's value so on next form load there is a new cookie value set for CRAFT_CSRF_TOKEN name to prevent next entry to be stored/updated in the same entry.

Trying to achieve this I've failed right after accessing to csrfTokenName.

Neither the property "csrfTokenName" nor one of the methods
"csrfTokenName()", "getcsrfTokenName()"/"iscsrfTokenName()" or "__call()" 
exist and have public access in class "Craft\HttpRequestVariable"
2

I guesss this could be accomplished using the cookies plugin or a simple jquery cookies library like js-cookie.

This is how you would go about it with the cookies plugin: set the cookies name without any value:

{{ setCookie( NAME ) }}
| improve this answer | |
  • The @khalwat 's cookies plugin helped. – Dominik Krulak Jan 22 '17 at 15:42

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.