Hi
Is it possible to get info about a current logged in extranet user, and when he/she was last logged in, prior to this current session?
Is it possible to get this info, in a template? If so, how can this be achieved?
/Hans
Hi
Is it possible to get info about a current logged in extranet user, and when he/she was last logged in, prior to this current session?
Is it possible to get this info, in a template? If so, how can this be achieved?
/Hans
Is this possible? :)
You can find it in [StatExtranet] table in the database.
If you are using the new "Tracking" feature in DW, you can find it in "TrackingEvent" table with the EventName being "User.Login" and the [TrackingEventEntityKey] being the userid.
Ok, perfect
How could I implement this in Template?
Any example on how this could be accessed?
/Hans
Something like this:
@{ if(Model.CurrentUser != null) { DateTime? lastlogin = null; using (var reader = Dynamicweb.Data.Database.CreateDataReader(String.Format("SELECT TOP (1) [StatExtranetTimeStamp] FROM [StatExtranet] where [StatExtranetAccessUserID] = {0} order by [StatExtranetTimeStamp] desc", Model.CurrentUser.ID))) { if (reader.Read()) { lastlogin = Dynamicweb.Core.Converter.ToNullableDateTime(reader["StatExtranetTimeStamp"], null); } } if (lastlogin.HasValue) { <span>User last logged in: @lastlogin.Value.ToString("g")</span> } else { <span>Seems like you have never logged in before. Welcome!</span> } } }
Fantastic Nicolai, thank you 👍🏻
You must be logged in to post in the forum