title: In ASP.net, how can I use Cookies and Session from helper classes?
body: <p>I handle the loading of user data in a single static class accessed by each of my aspx pages. I would like to add functionality to support Cookies and Session into this process. However, I am finding that the Response.Cookies object and the Session object are both unavailable to my util class.</p>
  
  <p>Essentially, what I have now is (in it's own file):</p>
  
  <pre><code>namespace myProject
  {    
      static class myUtil
      {
          public static myProject.User LoadUser()
          {
              //Look up user
          }
      }
  }
  </code></pre>
  
  <p>What I would like to do is:</p>
  
  <pre><code>namespace myProject
  {    
      static class myUtil
      {
          public static myProject.User LoadUser()
          {
              if (Session['user'] != null)
              { user = Session['user']; }
              else if (Response.Cookies['user'] != null)
              { user = Response.Cookies['user']; }
              else
              {               
                 //Look up user
              }
          }
      }
  }
  </code></pre>
  
  <p>How can I make this happen? In the current implementation, all references to Session and Response.Cookies are seen as undeclared objects.</p>
  
  <p>For reference, here are the current imports for the class:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Text.RegularExpressions;
  using System.Web.UI.Page;
  using System.Web.UI.WebControls;
  </code></pre>