You can try like this code:
After installation, open the wp-config.php
file in Site B’s installation root, and add (or replace) the following lines shortly after the database configuration, modifying them as needed to fit your configuration:
$cookiehash = md5("http://www.example.com/"); // Use Site A's URL
define(CUSTOM_USER_TABLE,'wp_users'); //Change 'wp' to match the prefix set during
define(CUSTOM_USER_META_TABLE,'wp_usermeta'); // Site A's installation
define('COOKIEPATH', "https://wordpress.stackexchange.com/"); //This path should reference Site A's root
define('SITECOOKIEPATH', "https://wordpress.stackexchange.com/"); //Should match 'COOKIEPATH'
define('COOKIEHASH', $cookiehash );