Can someone advise when this event is fired? I assumed it would be each time a member logs in? But it only seems to fire the first time a member logs in and then never again. I'm trying to update a property "previous_login" so I can determine when the user last logged in (as the last login date gets updated to the current date).
membership should handle this for you if you set the correct attributes on the membership provider. Altho I've seen posts about people reporting it doesn't work, in which case it would be great to add this to Codeplex.
Anyway, you could still write your own if you wire up to the LoggedIn event on the <asp:Login> control (Assuming you're using this), and update the member's data or write a record to custom db tables (depending on your scenario)
The problem seems to be there is a discrepency between what Umbraco classes as logged out and what Membership classes as logged out.
So the user is presented with a Membership login however they are still in the Umbraco cache. This can be solved by calling the below. This causes lots of problems across the site if these are not called and the user explicitly logged out.
Member.BeforeAddToCache Event Handler
Can someone advise when this event is fired? I assumed it would be each time a member logs in? But it only seems to fire the first time a member logs in and then never again. I'm trying to update a property "previous_login" so I can determine when the user last logged in (as the last login date gets updated to the current date).
Dan,
membership should handle this for you if you set the correct attributes on the membership provider. Altho I've seen posts about people reporting it doesn't work, in which case it would be great to add this to Codeplex.
http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.lastlogindate.aspx and http://our.umbraco.org/wiki/how-tos/membership-providers/umbracomembershipprovider-properties
Anyway, you could still write your own if you wire up to the LoggedIn event on the <asp:Login> control (Assuming you're using this), and update the member's data or write a record to custom db tables (depending on your scenario)
Cheers,
/Dirk
Membership handles the last login date.
The problem seems to be there is a discrepency between what Umbraco classes as logged out and what Membership classes as logged out.
So the user is presented with a Membership login however they are still in the Umbraco cache. This can be solved by calling the below. This causes lots of problems across the site if these are not called and the user explicitly logged out.
I've solved my problem by running the code from the login control rather than as an event handler.protected void OnLoggingIn(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e)
{
Member m = Member.GetMemberFromLoginName(Login1.UserName);
string previous_login="";
if (m != null)
{
previous_login = m.getProperty("last_login").Value.ToString();
}
if (Membership.ValidateUser(Login1.UserName,Login1.Password))
{
if (m != null)
{
m.getProperty("previous_login").Value = previous_login;
m.Save();
m.XmlGenerate(new System.Xml.XmlDocument());
}
}
}
is working on a reply...