Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in Salesforce by (11.9k points)

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

1 Answer

+1 vote
by (32.1k points)
edited by

I assume this would be cookie-based. 

If this is the case, you could try and confine it by tracking the cookie changes when you log in 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'); 

I will recommend you this salesforce certification course from Intellipaat. This training provides all the required skills and helps you to become a certified salesforce developer! 

Browse Categories

...