Filter hook 'comment_cookie_lifetime'

in WP Core File wp-includes/comment.php at line 596

View Source

comment_cookie_lifetime

Filter Hook
Description
Filters the lifetime of the comment cookie in seconds.

Hook Information

File Location wp-includes/comment.php View on GitHub
Hook Type Filter
Line Number 596

Hook Parameters

Type Name Description
int $seconds Comment cookie lifetime. Default YEAR_IN_SECONDS.

Usage Examples

Basic Usage
<?php
// Hook into comment_cookie_lifetime
add_filter('comment_cookie_lifetime', 'my_custom_filter', 10, 1);

function my_custom_filter($seconds) {
    // Your custom filtering logic here
    return $seconds;
}

Source Code Context

wp-includes/comment.php:596 - How this hook is used in WordPress core
<?php
 591  	 * @since 2.8.0
 592  	 * @since 6.6.0 The default $seconds value changed from 30000000 to YEAR_IN_SECONDS.
 593  	 *
 594  	 * @param int $seconds Comment cookie lifetime. Default YEAR_IN_SECONDS.
 595  	 */
 596  	$comment_cookie_lifetime = time() + apply_filters( 'comment_cookie_lifetime', YEAR_IN_SECONDS );
 597  
 598  	$secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
 599  
 600  	setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
 601  	setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );

PHP Documentation

<?php
/**
	 * Filters the lifetime of the comment cookie in seconds.
	 *
	 * @since 2.8.0
	 * @since 6.6.0 The default $seconds value changed from 30000000 to YEAR_IN_SECONDS.
	 *
	 * @param int $seconds Comment cookie lifetime. Default YEAR_IN_SECONDS.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/comment.php
Related Hooks

Related hooks will be displayed here in future updates.