I would like to know if there is a way to find out in APEX when an particular user is logged in directly or via the "Login As" feature from the organization's user list. The UserInfo class doesn't seem to provide any methods for this purpose and i need to know this in my apex code.
thanks in advance
Something is tracking that your session previously belonged to another user so that the "Logged in as XYZ ([email protected])" message can be displayed in the Salesforce UI.
I suspect this would be cookie based. If this is the case, you could try and isolate it by tracking the cookie changes when you login as another user. If you can find it then you can check for the presence of this cookie in Apex using
Cookie counter = ApexPages.currentPage().getCookies().get('loginAsCookieHere');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With