I'm using javascript to trigger my cookies and I've been told that the most reliable method to set cookies is to create them on the server side using php...
I already tested this code, but it creates the cookie on page load and I need it to be set only when the user clicks a link:
<a href="<?php
if (!isset($_COOKIE['my_test_cookie'])) {
ob_start();
setcookie("my_test_cookie", "1", time()+ (86400 * 90), "/");
ob_end_flush();
}?>" onClick="javascript:HideContent('div3');">Create Cookie</a>
Is it possible to build the cookie on php and only create him onclick event?
eg: < href="#" onclick="call_the_php_function_where_we_setup_the_cookie_variables();">click here to create the cookie</a>