I am wondering what is the best (e.g. most efficient, commonly accepted, industry standard) way to deal with the potential expiration of a session when you are regularly using the values stored in it in your code.
For example, I am often using (in C#) lines similar to the following:
Guid personGuid = (Guid)Session[SSPersonGuid];
I am checking in Page_Load whether the values are null and dealing accordingly, but the session might expire while the person is on the page, in which case when they click a button on the page, and we need to use something like the above, there will be a NullReferenceException.
Is the best way to handle this just to check for null before each usage like this:
if (Session[SSPersonGuid] == null) {...}
Or is there some kind of special thing I don't know about?