How To Set Cookies to Zero Days for a WordPress Blog

Uncomfortable with having your WordPress blog keep subscribers and editors signed in even after closing their browsers?

Here’s how to delete cookies from your WordPress blog. You’ll have to modify a file in the root directory of your WP installation.

Look for the file called wp-pass.php – it should contain php code like so:

require( dirname(__FILE__) . '/wp-config.php');


if ( get_magic_quotes_gpc() )
$_POST['post_password'] = stripslashes($_POST['post_password']);


// 10 days
setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH);


wp_safe_redirect(wp_get_referer());

See that line that starts with setcookie?

All you have to do is change “864000″ to “0″ and the cookie drops from 864,000 seconds to zero seconds. So, the setcookie line should look like this:

setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 0, COOKIEPATH);

When the user closes their browser, the session is complete and the cookie is dropped. Users will have to log in again the next time they visit your blog.

This entry was posted in WordPress. Bookmark the permalink.

One Response to How To Set Cookies to Zero Days for a WordPress Blog

  1. Pingback: Bookmarks about Cookies

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>