I have a cookie with data that I'm utilizing to populate a Gravity Forms form. However, after the form has been successfully submitted, I'd like to unset (or more accurately, expire) that cookie.
What I've tried
Initially, I thought the gform_after_submission
hook would work. I tried simply that pointing to a function that does the following:
public static function clearItems() {
setcookie('items', '', time() - 86400, '/');
}
The problem is that this hook is executed after the headers and therefore the updated value and expiration are not set.
Question
Is there any way to accomplish this (maybe I'm missing a hook of some kind that would work better)?
Another possibility that I've considered is to redirect to page and handle it there but I'd prefer not do handle it this way.