Automatically Log in New Users After Registration

add_action('woocommerce_registration_redirect', 'auto_login_new_user');
function auto_login_new_user($redirect_url) {
    $auto_login = true; // change to false to disable auto login
    if ($auto_login) {
        $customer_login = wc_get_customer_login_from_session();
        if ($customer_login) {
            wp_set_current_user($customer_login);
            wp_set_auth_cookie($customer_login);
        }
    }
    return $redirect_url;
}