Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7163881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:58:36+00:00 2026-05-28T13:58:36+00:00

I handle the loading of user data in a single static class accessed by

  • 0

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.

Essentially, what I have now is (in it’s own file):

namespace myProject
{    
    static class myUtil
    {
        public static myProject.User LoadUser()
        {
            //Look up user
        }
    }
}

What I would like to do is:

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
            }
        }
    }
}

How can I make this happen? In the current implementation, all references to Session and Response.Cookies are seen as undeclared objects.

For reference, here are the current imports for the class:

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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:58:37+00:00Added an answer on May 28, 2026 at 1:58 pm

    Session in class file

    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Web;  
    using System.Web.SessionState;  
    /// <summary>  
    /// Summary description for GetSessionHelper  
    /// </summary>  
    public class SessionHelper : IRequiresSessionState  
    {  
        public object GetSession(string key)  
        {  
            //check session   
            if (HttpContext.Current.Session[key] != null)  
            {  
                //return session value  
                return HttpContext.Current.Session[key];  
            }  
            else  
            {  
                //return empty string  
                return string.Empty;  
            }  
        }  
    }  
    

    Cookies in class file

     if (HttpContext.Current.Request.Cookies["CodeF"] != null)
     {
        string background = HttpContext.Current.Request.Cookies["CodeF"]["BackImage"].ToString();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I handle commands inside a RoutedCommand class that implements RoutedUICommand. This would help me
What is the best way to handle browser-specific CSS file loading? Assume you are
For a project I'm working on for loading/storing data in files, I made the
Currently, I'm using AsyncTask to handle Http connection and retrieve data as JSON format.
Simple question regarding data persistance between application sessions. My application allows the user to
Among other, I have two pages in my Web Site project. Default.aspx and TeacherControlPanel.aspx.
I'm trying to figure out the best way to handle loading objects with different
I want to handle a scenario where user hits a url of /somePage.cfm when
The goal is to have a single-threaded event-driven framework. The end-user will do something
I would like to have optimized version of my WinForms C# based application for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.