$user = get_user_by('id', $userid);
wp_clear_auth_cookie();
wp_set_current_user($user->data->ID);
wp_set_auth_cookie($user->data->ID);
« How to use Odoo External Api in PHP > 8.0 A Comprehensive Guide to Perform UI Audit of Website[Complete Checklist] »