Set cookie in wordpress for current user info.
-
0
down vote
favoriteI’m trying to add a chatroom to our wordpress site. The company that we purchased the chatroom software from is doing a couple custom additions for us. For one of the additions they asked that we set a cookie to collect current user data.
I apologize, I’m extremely new to PHP so please be gentle!
For example, to collect User-ID number, I’ve tried adding this to our function.php file:
$current_user = wp_get_current_user(); add_action( 'init', 'my_setcookie' ); function my_setcookie() { setcookie( 'id', $current_user->ID, 3 * DAYS_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); }
This is not producing anything when I look at the cookies being collected in my browser.
This seems to be a very opaque topic, as I’ve not found much information about it online.
Is there a way to set a cookie to collect current user data?
Thank you!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Set cookie in wordpress for current user info.’ is closed to new replies.