<p>I guesss this could be accomplished using the <a href="https://github.com/nystudio107/cookies" rel="nofollow noreferrer">cookies plugin</a> or a simple <a href="https://github.com/js-cookie/js-cookie" rel="nofollow noreferrer">jquery cookies</a> library like js-cookie.</p>

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

<pre><code>{{ setCookie( NAME ) }}
</code></pre>

CC BY-SA 3.0
2017-01-22T15:42:10.827Z
The @khalwat 's cookies plugin helped.
Dominik Krulak
CC BY-SA 3.0
2017-01-22T13:17:57.033Z
2017-01-22T13:17:57.033Z
Jan_dh
<p>I need to delete the <code>CRAFT_CSRF_TOKEN</code> cookie when a form submission reaches certain/success page. I'm using <a href="https://craftcms.com/docs/config-settings#csrfTokenName" rel="nofollow noreferrer">CSRF</a> stripped cookie's value to store entry title like this:</p>

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

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

<p>Trying to achieve this I've failed right after accessing to <code>csrfTokenName</code>. </p>

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

<security><csrf>
Delete CSRF cookie on submit form success
# Delete CSRF cookie on submit form success

(Asked by: username_0 on 2017-01-22)

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"

**Tags:** security, csrf

---

## 1 answers

### Answer by username_1 on 2017-01-22. Score: 2 | Accepted answer

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 ) }}

> **Comments:**
> **username_0**: The @khalwat 's cookies plugin helped.  

---

