See my updated answer, now i tried as per your condition and my url is like now
http://www.example.com/?query=yes
add_action('init', 'my_cookie');
add_action('init', 'signup_validate_insert');
function signup_validate_insert() {
if(isset($_REQUEST['query'])) {
$errors = 'my_error';
setcookie("my_cookie", $errors, time()+3600);
wp_redirect(home_url('shortcode-9/'));
die();
}
}
function my_cookie() {
if(isset($_COOKIE['my_cookie'])) {
echo $_COOKIE['my_cookie'];
}
}
it is for me working nice. am i right? Reply your thoughts.