You need to sign in to do that
Don't have an account?

User Login Info
Hi,
is it possible to to see whether a particular user is logged into salesforce through apex?
my use case is after the userId's are created , i have to check whether that the user logged into salesforceor not,
if not i have to send them a reminder email.
can anyine please tell me asolution to achieve this
Thanks much !
there's a lastLoginDate field on User, no need to do (a horribly expensive) query on LoginHistory.
All Answers
You can try this
get the user id of the user by querying based on username like
user usr = [select id, username from user where username=: 'xyz@sf.com'];
LoginHistory[] logHist = [select logintime from LoginHistory where userid =: usr.id];
If(logHist.size() > 0)
By checking the size of the login history you can decide
there's a lastLoginDate field on User, no need to do (a horribly expensive) query on LoginHistory.
Thanq Simon and Sandeshd, Appriciate your help.
Hi Simon,
I saw it in the user details page but I didnt find it in fields section under user. so I gave that query. Can you please let me know where can I find that field details
Hi,
In your user list page, create a new view and add the last login date to that view. So whenever you select that view you can find last login date for all users.
Thanks.
ok but how do we do it programatically through apex...pls suggest
select id, lastLoginDate from user
SELECT Username, LastPasswordChangeDate, LastLoginDate FROM User