Login

For the record, setting cookies in WordPress is special.

Author:neo yang Time:2023/08/31 Read: 7653

I've been stuck on this little problem for a day.

Setting cookies in WordPress is special.It should be written in the theme's functions file and loaded into the init hook.

function custom_set_cookie() { setcookie( 'key', 'value', time() + 3600 * 24, COOKIEPATH, COOKIE_DOMAIN ); } add_action( 'init', 'custom_set_cookie' );
tags:


copyright © www.lyustu.com all rights reserved.
Theme: TheMoon V3.0. Author:neo yang