Generally functions hooked with init
action will be available on every page and posts with in WordPress. it will immediately fire upon WP load. so maybe something like below will work.
function ao_check_cookie() {
//Your code here.
}
add_action( 'init', 'ao_check_cookie' );