if (is_user_logged_in()){
if(!isset($_COOKIE['alertuser'])){
// set cookie
$timer = time()+86400;
setcookie('alertuser', '1' $timer);
// show alert
function load_alert(){
wp_register_script('alert', get_template_directory_uri() . '/js/alert.js', array( 'jquery' ));
wp_enqueue_script( 'alert');
}
add_action('admin_enqueue_scripts', 'load_alert');
}
} else {
$timer = time()-86400;
setcookie('alertuser', '', $timer); // <-problem here
}
I’m trying to attach a js file only when a customer first logs in. Upon signing out the cookie should get deleted, but isn’t. Why?
(Maybe this is more of a php question that WP specific, if so, sorry for posting it here.)
looks like I needed add a path to my cookie. This fixed it:
and