setcookie doesn't work in submit function nor tpl.php I just copy and pasted set cookie sample code(http://www.w3schools.com/php/php_cookies.asp) to my module and tpl.php

In my module, I put the setcookie in my submit function as below:

function custom_request_price_form_submit($form,&amp;$form_state){
   $cookie_name = "user";
   $cookie_value = "John Doe";
   setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day

   if(!isset($_COOKIE[$cookie_name])) {
       drupal_set_message("Cookie named '" . $cookie_name . "' is not set!");
   } else {
       drupal_set_message("Cookie '" . $cookie_name . "' is set!&lt;br&gt;");
       drupal_set_message("Value is: " . $_COOKIE[$cookie_name]);
   }
}


Im my node--XXX.tpl.php, I just copy the code without modification as below:

$cookie_name = "user";
$cookie_value = "John Doe";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day

if(!isset($_COOKIE[$cookie_name])) {
    echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
    echo "Cookie '" . $cookie_name . "' is set!&lt;br&gt;";
    echo "Value is: " . $_COOKIE[$cookie_name];
}


However, no matter how I refresh the webpage, the message always shows "Cookie named 'user' is not set!" 

I also tried user_cookie_save function, but no luck. Does anyone know why my cookie setting doesn't work?
Thank you everyone, I got the answer. 
It seems Drupal supports session instead of cookie.(Sorry I cannot find the reference again.) Therefore, I used session to implement my function. 

Here are some reference:

Example for session:
https://www.drupal.org/node/360542

How to set session expiration:
https://www.drupalgardens.com/documentation/cookie/expire