WordPress Cookie Security - Persistent Cookie comment_author change to session cookie
If you just want to change expiration date, you can use comment_cookie_lifetime filter.
E.g. to expire it after two years:
add_filter('comment_cookie_lifetime', 2*YEAR_IN_SECONDS);
To change it to session, you need to remove default wp_set_comment_cookies from set_comment_cookies hook and add your own one to set session cookie.
Example:
remove_action('set_comment_cookies', 'wp_set_comment_cookies', 10, 2);add_action('set_comment_cookies', function(\WP_Comment $comment, \WP_User $user){ // set session}, 10, 2);