1

How to Check Save User's Credendiatals in Session in C#? Does anyone know how can I check whether a session is empty or null in .net c# web-applications?

2 Answers2

1

Try this

if( Session["User"] == null || string.IsNullOrEmpty(Session["User"].ToString()))
{
  //return to login ;
}
else
{
  // your default page
}
sujith karivelil
  • 27,818
  • 6
  • 51
  • 82
Nazir Ullah
  • 600
  • 3
  • 13
0
if(Session["User"] !=null){
     Response.Redirect("http://www.google.com",true);
}
else
{
     Response.Redirect("~/login",true);
}
Sami
  • 3,464
  • 3
  • 16
  • 26