WordPress single sign on using cookies with shared user role functionality between more than 2 wordpress subdomains

did you try to use a plugin instead,

https://premium.wpmudev.org/forums/topic/configure-single-sign-on-for-multiple-wordpress-sites-and-make-it-secure

have a look at this and this one
https://wordpress.org/plugins/wp-multisite-sso/

hope this might help

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)