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
  • 28,671
  • 6
  • 55
  • 88
Nazir Ullah
  • 610
  • 5
  • 13
0
if(Session["User"] !=null){
     Response.Redirect("http://www.google.com",true);
}
else
{
     Response.Redirect("~/login",true);
}
Sami
  • 3,686
  • 4
  • 17
  • 28