Spam comments are a huge problem for some WordPress users. As your site grows, spamming programs will find you and start to target your site with unwanted comments.

There are some great ways to block spam including the Akismet plugin and adding a CAPTCHA plugin to your site. However, these are not the only ways to block spam. You can also do it through Cookies.
<h2>Using the Cookies for Comments WordPress Plugin</h2>
The <a href="https://wordpress.org/plugins/cookies-for-comments/">Cookies for Comments WordPress Plugin</a> can help eliminate spam comments from your WordPress website. Install and activate this plugin and it will work right out of the box. You won't need to configure anything or change any settings.
<h2>How does the Plugin Work?</h2>
Most of the spam comments you receive don't actually come from an actual person. Instead, they come from spam bots. These bots are actually software scripts that spend their time looking for comment forms and posting comments. Since these programs are used to submit thousands of comments, they don't load images or stylesheets from websites. They just load the text to figure out if there is a form for a comment.

When you install the Cookies for Comments plugin, it will load an image or stylesheet on a page when it has been accessed. When this happens, the user's browser will install a cookie. If a user tries to post a comment and the cookie isn't present, the plugin will identify them as a spam bot. The comment will also be marked as spam and submitted as spam.
<h2>Can you Completely Block them From Posting a Comment?</h2>
If you want to use this plugin and completely block the spam bots, you will need to change a little bit of code. This is done by finding the cookies, which you can do by right clicking on your website and selecting "view source" from the menu.

<img class="alignnone size-full wp-image-7460" src="https://itxdesign.com/wp-content/uploads/2014/12/ViewPageSource.png" alt="View Page Source" width="325" height="202" />

Now, you will have a new tab open with the code for your website. You will need to scroll to about the middle of the source code and look for a code that looks like this:

<img class="alignnone size-full wp-image-7464" src="https://itxdesign.com/wp-content/uploads/2014/12/Cookie_Code.png" alt="Cookie Code" width="641" height="178" />

&nbsp;

The cookie value is the string of number and letters found after the css.php?k=. In the code above it is, 9634eab89e9d848c824a68ddc6118c93.

You will need to connect to your website with your FTP client and edit the .htaccess file. You will just need to enter this code before anything else in this file to block spam comments with this plugin completely.

<img class="alignnone size-full wp-image-7462" src="https://itxdesign.com/wp-content/uploads/2014/12/HTaccessCode.png" alt="HTaccess Code" width="486" height="45" />

Replace the strings of XXXXX with your cookie value.

If you follow these steps and use the cookies for comments plugin, you will be able to block the comments coming from spammers in WordPress.