Disable WordPress Comment Form User Details Cookie

Print View Mobile View

When a person posts a comment on a WordPress site, the information – name, email, and website – they provide is stored in a cookie in the browser. These details are automatically fetched and prefilled in the comment form across the site, saving a visitor from unnecessary repetitive typing of the same information in all comment forms.

If for some reason (like the new European Union’s directive to require permission for saving cookies) you would like to disable this functionality, it can be done with this single line of code in the functions.php file:

remove_action( 'set_comment_cookies', 'wp_set_comment_cookies' );

Cookies are set by wp_set_comment_cookies() and this function is hooked into set_comment_cookies. Above action will remove it the function.

And thats it – no cookies set when someone posts a comment.