using session for login and logout in asp.net
firstly open the "Global.aspx".
then create a function there
protected void Application_Start()
{
//we give the name of the session here and declare it null ..username is the name of the session
//we can change it according to our needs
Sesssion["username"]="";
}
now we can create the function where we are login as
function boolean login( string username, string password)
{
// firstly we match the login details from the database.
if(username == logincredintialfromdb && password ==logincredintialfromdb )
{
// the values are matched here so are assiging the value to the session variable
Session["username"]= username ;
return true;
}
else
{
return false;
}
}
then create a function there
protected void Application_Start()
{
//we give the name of the session here and declare it null ..username is the name of the session
//we can change it according to our needs
Sesssion["username"]="";
}
now we can create the function where we are login as
function boolean login( string username, string password)
{
// firstly we match the login details from the database.
if(username == logincredintialfromdb && password ==logincredintialfromdb )
{
// the values are matched here so are assiging the value to the session variable
Session["username"]= username ;
return true;
}
else
{
return false;
}
}
Comments
Post a Comment