As a best practice you should check session exist first
if(Session["myVal"] != null)
{
string myVal = Session["myVal"].ToString();
}
else
{
Response.Redirect("Login.aspx")
}
if you directly call
Session["myVal"].ToString()
, you will get "'Object reference not set to an instance of an object'." in case of session value null.
you may need to do this on each and every page. but there is a easy way by using global aspx file
Check these answers[
^]
if you need to increase session timeout, then check
these answers[
^]