Skip to content

Instantly share code, notes, and snippets.

@miclow
Last active October 12, 2018 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miclow/837a5a49bdf2bb2461312bd7f0552c1a to your computer and use it in GitHub Desktop.
Save miclow/837a5a49bdf2bb2461312bd7f0552c1a to your computer and use it in GitHub Desktop.
PHP set cookie (user_is_admin) when visitor access the admin of Wordpress
function my_exclude_admin_cookie() {
$expire_time = time() + 60 * 60 * 24 * 180;
setcookie( 'user_is_admin', 'true', $expire_time, '/' );
}
if( is_admin() ) {
add_action('init', 'my_exclude_admin_cookie');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment