ASP.NET Is it possible to handle all the null session checking in masterpage
<p>I have the following steps in my webpage</p>

<p>1) User Logs in and I set the following session variables</p>

<pre><code>     Session("userName") = reader_login("useremail").ToString()
     Session("userId") = reader_login("user_ID").ToString()
     Session("firstName") = reader_login("firstName").ToString()
</code></pre>

<p>2) Now on my logged in VB.NET templates I reference a MasterPage called LoggedIn.Master. In Which I added the following method to check for the above null session variables. And if they null to redirect back to login page.</p>

<pre><code>Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

    '#Check that User is Logged in, if not redirect to login page
    If (Session("userId") Is Nothing) Or (Session("userName") Is Nothing) Or (Session("firstName") Is Nothing) Then
        Response.Redirect(ConfigurationManager.AppSettings("site_base_url").ToString &amp; "login/", False)
    End If
</code></pre>

<p>3) Now my question is if I want to use any above 3 Session variables in different .net templates or usercontrols referencing the above master page  do i need to AGAIN add the check</p>

<pre><code>        If (Session("userId") Is Nothing) Or (Session("userName") Is Nothing) Or (Session("firstName") Is Nothing) Then
        Response.Redirect(ConfigurationManager.AppSettings("site_base_url").ToString &amp; "login/", False)
    End If
</code></pre>

<p>In the respective pages or will the check in master page do. Because at the moment i.e. if in a usercontrol I attempt to do i.e.</p>

<pre><code>customerName.Text = Session("userName").ToString()
</code></pre>

<p>or</p>

<pre><code>Response.Write(Session("userName").ToString())
</code></pre>

<p>I am getting the error
Object reference not set to an instance of an object.</p>

<p>customerName.Text = Session("userName").ToString()</p>
