How to send variables to function.php in wordpress
<p>I want to save cookies using onclick function in my wordpress blog. So I put this code in function.php</p>

<pre><code>add_action( 'init', 'setting_my_first_cookie' );

function setting_my_first_cookie() {

echo $v_username;
echo "This can be echo";
setcookie('username' , 'Rajeasdasdsdh' , time()+30*24*60*60);
}
</code></pre>

<p>On index.php</p>

<pre><code>&lt;?php 
global $v_username;
$v_username="demo"; 
$v_value="asd";
?&gt;

&lt;th&gt;&lt;a href="" onclick="setting_my_first_cookie()"&gt;Set Cookie&lt;/a&gt;&lt;/th&gt;
</code></pre>

<p>I am retriving this cookie using this code:</p>

<pre><code>&lt;?php
// Accessing an individual cookie value
echo $_COOKIE["username"];
?&gt;
</code></pre>

<p>Everything is working but I cant set that cookies using variable. I cant pass <code>$v_username</code> to function. How to do it?
I want echo or alert <code>$v_username</code> in my function <code>setting_my_first_cookie()</code></p>