<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How can I find out if a user is logged in?</title><link>https://answers.axonivy.com/questions/445/how-can-i-find-out-if-a-user-is-logged-in</link><description>&lt;p&gt;I need to know if a particular user has an active session in an Ivy application, or in other words whether he is currently loggedin.&lt;/p&gt;
&lt;p&gt;I can get a particular IUser with &lt;code&gt;Ivy.session.getWorkflowContext().getSecurityContext().findUser("username")&lt;/code&gt;
and I can get all the sessions with
&lt;code&gt;ivy.session.getWorkflowContext().getSecurityContext().getSessions()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;But I cannot find the way to see if the user is part of one of these sessions?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/445/how-can-i-find-out-if-a-user-is-logged-in" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 08 Mar 2012 09:58:56 -0500</lastBuildDate><item><title>Answer by Reto Weiss</title><link>https://answers.axonivy.com/questions/445/how-can-i-find-out-if-a-user-is-logged-in/446</link><description>&lt;p&gt;You can do something like that with the code snippet below: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import ch.ivyteam.ivy.security.ISession;
import ch.ivyteam.ivy.security.IUser;

IUser user = ivy.session.getWorkflowContext().getSecurityContext().findUser("username");
for (ISession session : ivy.session.getWorkflowContext().getSecurityContext().getSessions())
{
    if (session.getSessionUser().equals(user))
    {
        ivy.log.info("Session found with user");
    }
}
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Thu, 08 Mar 2012 09:58:56 -0500</pubDate><guid>https://answers.axonivy.com/questions/445/how-can-i-find-out-if-a-user-is-logged-in/446</guid></item></channel></rss>