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 6869567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:34:25+00:00 2026-05-27T03:34:25+00:00

I am currently using session to hold the user ID at my web application.

  • 0

I am currently using session to hold the user ID at my web application. And i read a lot about sessions is evil, so my plans is to find another solution.

So my next step is to use encrypted cookie.
Something like:

userInformation: ENCRYPT(UserID,subdomain,someComputerUniqueValue,hashvalueOftheString)

each user has their own subdomain, so the UserID and Subdomain must match.
But. Now at almost every page i call the session value to get the userID.
I want to change this to some kind of variable, but what kind of variable?!
I am now setting the session value inside a httpmodule. in the

public void Application_PreBeginRequest

Is it possible to create a variable within application_prebeginRequest and read it somewhere else during the creation of the page. for example in the masterpage, och the contentpage. or the classes that is used at that specific page.
WHen the page is created and sent to the client, the variable should die.

What kind of variable am i looking for? is it global variable? if not, what is global variable?

Thanks for reading!
Mattias R.

Edit:

This cookie is not for authentication. I want to save the ID of the user connected to the subdomain, so i dont have to run the “SELECT ID from account where subdomain=’somethin'” query each time a page is visited.

  • 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-27T03:34:26+00:00Added an answer on May 27, 2026 at 3:34 am

    You can store what you need inside the HttpContext.Current.Items. Items put inside that will live only during the current web request and will be available globally in your web application.

    // Global.asax
    void Application_BeginRequest(object sender, EventArgs e)
    {
        HttpContext.Current.Items["hello"] = DateTime.Now;
    }
    // Default.aspx
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = HttpContext.Current.Items["hello"].ToString();
        }
    }
    

    By the way, at Application_BeginRequest event, the Session object isn’t available.

    For more information about HttpContext.Current.Items, look at https://web.archive.org/web/20201202215202/https://www.4guysfromrolla.com/articles/060904-1.aspx.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I'm using a session-per-request approach to manage Hibernate sessions in a Java web
I am currently running a simple EJB application using a stateless Session Bean. I
Currently I am loading data from a previous session into my application using the
currently im using session to log in the user. but when i close the
I'm currently using an Open Session in View pattern in an ASP.NET WebForms application
I am currently using ASP.Net state server to store session data in my application.
Currently using System.Web.UI.WebControls.FileUpload wrapped in our own control. We have licenses for Telerik. I
Im currently using vs2008 with asp.net mvc framework for web development. Im missing a
I'm currently using the ActiveRecord-based session store for my Rails app and I have
I am currently using the Tonic PHP framework to build a RESTful application (

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.