how to display last login date
i have a label i want to show the user last login date.how it would be plz help me .i just want to entry the date when user login how it would be done lz tell me in detail
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vignesh KumarPosted Jun 17, 2013, 6:36 AM
Try this, I have been using this for myself.
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
Login login = (Login)sender;
// Get the user attempting to login
MembershipUser user = Membership.GetUser(login.UserName);
if ( user != null )
{
// Get the date the user last logged in before
DateTime dtLastLogin = user.LastLoginDate;
// To validate user -- if success then set the authentication
if (Membership.ValidateUser(login.UserName, login.Password))
{
Session["LastLoginDate"] = dtLastLogin;
e.Authenticated = true;
}
}
}
Kiresh GangariyaPosted Jun 17, 2013, 2:13 AM
mark this post as helped.
minu khandelwalPosted Jun 17, 2013, 2:05 AM
Bhabani prasad DashPosted Jun 17, 2013, 1:17 AM
BalaPosted Jun 17, 2013, 12:55 AM
- Command is
-----------------
- Select Last(Column_name) from Table_name where User_ID = '"+User_ID.Text+"' ;
- Create Data Reader with obj Name,
- Store that Data Reader like dr.Read()
lblLastdate.Text = dr.GetString(No.);
Kiresh GangariyaPosted Jun 17, 2013, 12:35 AM
2) Now in Login Page update this Field by DateTime.Now() using LoggedIn UserId In User Table.
when user loggedin then retive that LastLoginDate using LoggedIn UserId to your Label.
Thanks,