sanitize_comment_cookies()
Clears the comment form fields name, email, and website that are in cookies.
The function takes nothing and returns nothing, but works directly with the superglobal variable $_COOKIES and clears the corresponding values in it.
Hooks from the function
Returns
null. Nothing.
Usage
sanitize_comment_cookies();
Examples
#1 Clearing cookie values for the comment form before displaying it on the screen
Suppose we use the function wp_get_current_commenter() to get the data of the name, mail, and site of the unauthorized user, which are in the cookies. But we will get raw data, to clear it before outputting it, we have to use sanitize_comment_cookies():
// Clean up the data sanitize_comment_cookies(); // now data is safe to use $commenter = wp_get_current_commenter(); // Output the data echo $commenter['comment_author']; echo $commenter['comment_author_email']; echo $commenter['comment_author_url'];
Changelog
| Since 2.0.4 | Introduced. |