title: Adding Custom Cookie To Wordpress
body: <p>Hi I am pretty new to wordpress,php and all this editing thing. I want to add a new cookie to wordpress upon authentication with name "xxx" and value "(currentusername)". I already read <a href="http://wptheming.com/2011/04/set-a-cookie-in-wordpress/" rel="nofollow">http://wptheming.com/2011/04/set-a-cookie-in-wordpress/</a> . I add the required code to the functions.php of my code however I don't know how to invoke it such that the currentusername logginned is added to the cookie.
  Thanks in advance</p>
  
  <p>Here is the code on the other website which I inserted in my functions.php</p>
  
  <pre><code>function set_newuser_cookie() {
  if (!isset($_COOKIE['sitename_newvisitor'])) {
      setcookie('sitename_newvisitor', 1, time()+1209600, COOKIEPATH, COOKIE_DOMAIN, false);
  }
  </code></pre>
  
  <p>}
  add_action( 'init', 'set_newuser_cookie');</p>