This can be achieved with Two Cookie.
- Saves the unix time of user visits first time. Expiration time set to a higher value, A cookie that never expires.
- Set another cookie that is valid for 24 hours.
Code
function wpse144762_check_accessed(){
if( !isset($_COOKIE['first_time']) ) {
// user visiting for the first time
setcookie('first_time', 'yes', time() + 60 * 60 * 24 * 365 * 10); // expires in 10 years
define("ACCESSED", false);
}elseif (
!isset($_COOKIE['accessed'])
&& intval($_COOKIE['first_time']) > time() - 60 * 60 * 24 * 7
) {
setcookie('accessed', 'yes', time() + 3600*24);
define("ACCESSED", false);
}else{
define("ACCESSED", true);
}
}
add_action("template_redirect", "wpse144762_check_accessed");
Code is not tested. But this should give you the idea