i am writing a plugin, where i am setting a cookie. When i set cookie using php method it show warning.
Warning: Cannot modify header information - headers already sent by (output started at
if i use wordpress action, for setting cookie its not working. I have use this in my theme functions.php file its working fine but not working in plugin code.
Here are code samples:
Using php method
setcookie( 'sm_js_cookie', 1, time()+3600*24*100,'/');
Using wordpres action:
function set_newuser_cookie() {
setcookie( 'sm_js_cookie', $_SERVER['REMOTE_ADDR'], time()+3600*24*100,'/');
}
add_action( 'init', 'set_newuser_cookie');
Please help me to find its solution.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire