How to set a cookie based on a page Get variable?

On the page where you want to set the cookie write this code and check if(get_query_var(‘my_var’) == ‘somevalue’){ setcookie(‘my_cookie’, get_query_var(‘my_var’), strtotime(‘+1 day’)); } If we go with your code then it will set coookie on every page who having query variable ?my_var=somevalue

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)