title: wordpress set cookie in shortcode
body: <p>I am writing a wordpress plugin where I have a shortcode. This shortcode generates and handles a form. When the form is submitted, a value is stored in a cookie with:</p>
  
  <pre><code>$result = setCookie('cookieName','cookieValue');
  </code></pre>
  
  <p>Result then returns false, meaning the cookie is not set. This is not suprisingly, since headers are already sent when the shortcode is executed. I am looking for a way to solve this problem.</p>
  
  <p>I have found multiple similar questions here. Most answers were: set the cookie earlier, but that is not really an option for me.</p>
  
  <p>The only thing i could think of was output buffering everything, but I am not sure what is the correct way to do this in wordpress (which hooks, how to keep things compatible with other plugins etc). I also wonder if there is a built-in solution, since it seems to me that I will not be the only one with this problem.</p>