# Forget Post Passwords When the Browser Closes

> Makes the cookie that remembers a protected post's password last only until the browser is closed, instead of the default 10 days, which matters on shared and public computers.

- Type: PHP
- Runs: Run everywhere
- Category: [Security](https://wpide.com/library/category/security/)
- Tags: passwords, cookies, content
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/sec-post-password-session-cookie/

## Code

```php
add_filter( 'post_password_expires', '__return_zero' );
```

## Notes

Visitors need to enter the password again in each new browser session.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Forget Post Passwords When the Browser Closes" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
