 <p>You can use <code>include_once</code> or <code>include</code> at your index.php</p> <p>Try this code for index.php :</p> <pre><code>&lt;?php global $v_username; $v_username="demo"; $v_value="asd"; include_once('function.php') ?&gt; &lt;th&gt;&lt;a href="" onclick= &lt;?php setting_my_first_cookie(); ?&gt; &gt;Set Cookie&lt;/a&gt;&lt;/th&gt; </code></pre>