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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kiresh Gangariya52 reputationPosted Jun 16, 2013, 8:35 PM EDT
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,
Bala43 reputationPosted Jun 16, 2013, 8:55 PM EDT
- 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.);
Bhabani prasad Dash168 reputationPosted Jun 16, 2013, 9:17 PM EDT
minu khandelwal4 reputationPosted Jun 16, 2013, 10:05 PM EDT
Kiresh Gangariya52 reputationPosted Jun 16, 2013, 10:13 PM EDT
mark this post as helped.
Vignesh KumarRank #1,578 · 1K reputationPosted Jun 17, 2013, 2:36 AM EDT
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;
}
}
}