i am working on asp.net 2.0 and sql server 2005 i am using login authentication where userid = CJ and password = 123 when i click on login button the text welcome CJ must be displayed. on redirected page any help will be welcome
A:
Store your user data in a session after the user was validated, and clean the session on logout. Storing you logged user in a session you can access you user from any page.
Andrei Bularca
2010-09-28 14:55:16
can u show a example please
2010-09-28 14:57:43
go to google, and type in "ASP.NET Forms Authentication".
RPM1984
2010-09-28 23:35:00
A:
If your user is valid store it in a session :
MyUser currentUser = UserLogin(userName, password);
if(currentUser!=null){
Session["loggedUser"] = current;
Response.Redirect("~/Default.aspx");
}
else
{
//User authentication failed
}
When you access the logged user check if the session variable is null :
if(Session["loggedUser"]!=null)
{
MyUser currentUser = (MyUser)Session["loggedUser"];
}
When you click the logout button clean your session variable (inside your Logout method) :
Session["loggedUser"] = null;
Good luck!
Andrei Bularca
2010-09-29 06:46:18