add_action( \'wp\', \'Store_cookies_of_user\' );
function Store_cookies_of_user() {
$ids = isset( $_COOKIE[\'bsf_docs_cookies\'] ) ? explode(\'a\', $_COOKIE[\'bsf_docs_cookies\']) : array();
if( ! in_array(get_the_ID(), $ids) ) {
// Add to array.
$ids[] = get_the_ID();
// Impload with `a` stirng!
$ids = implode(\'a\', $ids);
// Increase currend doc view count with 1.
$count = (int) get_post_meta( get_the_ID(), \'views\', true );
update_post_meta( get_the_ID(), \'views\', ($count+1) );
// Set updated ids list.
setcookie(
\'bsf_docs_cookies\',
$ids,
time() + 86400,
COOKIEPATH,
COOKIE_DOMAIN,
false,
true,
);
}
}