Are you trying to get that implemented for front-end users or in the manager?
What you’re looking for is called single sign on, or SSO. Typically people use SSO to sign people into different systems from the same login but if both systems are MODX you could also do that.
The basic way to log someone in programmatically (so without them filling in their username/password on site 2) is by getting the user and calling
addSessionContext, e.g.: https://gist.github.com/leviwheatcroft/70d72c2f2b3ae4e0ea4b
What you need to do though is talk with site 1 to see if the user is already logged in and if so securely transmit the necessary information back and forth. That’s something OAuth flows are often used for.
So you want to use MODX (example1) as the source of authentication?
In that case the code I linked to is not useful, as that’s for when example2 was your source of authentication.
There’s an oauth extra that you could use on your MODX site to handle the signing in through an oauth flow. It then depends on what example2 runs on and what that supports on if that will work.