SharePoint - Is it possible to capture sharepoint sign out session id?

Asked By uday on 21-Dec-11 07:41 AM
Hi,

Is it possible to capture SharePoint Portal Sign out ?
i want to capture the session id while sign out and insert it into database.
Is it possible to do?
can anyone help me in this issue?
Riley K replied to uday on 21-Dec-11 11:16 AM

Surprisingly there doesn't seem to be a way to get this information using the SharePoint API. However you could retrieve this information from the IIS logs. I think that doing it this way would be more precise than getting it from AD, because a user can login into a system without ever visiting SharePoint.


Another approach would be to use SharePoint auditing. As far as I know there isn't a specific login audit event, but you could audit when a user reads the SharePoint welcome page. Using SPAuditQuery you can retrieve some details.


Regards
Jitendra Faye replied to uday on 22-Dec-11 02:04 AM
You can use SessionContext.sessionID Property  to get session id in sharepoint.

Follow this link for more details-

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.portal.webcontrols.wsrpwebservice.sessioncontext.sessionid.aspx

Hope this will help you.

uday replied to Jitendra Faye on 22-Dec-11 04:57 AM
Thanks for the reply,
but is it possible to find out the user has logged out from the SharePoint Site?
Jitendra Faye replied to uday on 22-Dec-11 06:05 AM
Try this code-

SPWeb LeaveWeb = SPContext.Current.Web;
          SPUser sUser = LeaveWeb.CurrentUser;
          string strLoginId = sUser.LoginName;
uday replied to Jitendra Faye on 22-Dec-11 07:28 AM
thanks for the code vickey,
but this code gives the current user right.
but i want to capture user log out event, while logging out i want to capture that session id and insert it into database.
i want to know whether the user logged out from site or not.
while logging out, the session id will time out right. so  i need to check whether the user has logged out or not.