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

  • Home
  • SEARCH
  • 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 6056593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:23:39+00:00 2026-05-23T08:23:39+00:00

I used a custom SessionWrapper class for handling Session in my ASP.NET project. It

  • 0

I used a custom SessionWrapper class for handling Session in my ASP.NET project. It seems ok but I have recently found that it has hilarious error. If many user login to my website, their session will be exchanged or mixed. User A will has session of User B and maybe User C has Session of User A. It may change after User refresh the page.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

namespace MyNamespace
{
    public class SessionWrapper
    {
        public static string USER_SESSION = "userSession";

       public static void SetUserSession(string email, Dictionary<int, DateTime> products)
        {
            UserSession userSession = new UserSession() { Email = email, Products = products };
            System.Web.HttpContext.Current.Session.Add(USER_SESSION, userSession);
        }

        public static UserSession GetUserSession()
        {
            if (System.Web.HttpContext.Current.Session[USER_SESSION] != null)
            {
                return System.Web.HttpContext.Current.Session[USER_SESSION] as UserSession;
            }
            return null;
        }

        public static void RemoveUserSession()
        {
            if (System.Web.HttpContext.Current.Session[USER_SESSION] != null)
            {
                System.Web.HttpContext.Current.Session.Remove(USER_SESSION);
            }
        }
    }

    public class UserSession
    {
        private string email;
        private Dictionary<int, DateTime> products = new Dictionary<int, DateTime>();

        public string Email
        {
            get;
            set;
        }

        public Dictionary<int, DateTime> Products
        {
            get;
            set;
        }
    }
}
  • 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-23T08:23:39+00:00Added an answer on May 23, 2026 at 8:23 am

    The only reason apart from some strange code in application like Jonas H noticed is that you are testing it in either one browser instance in separate tabs or two instances of the same browser.

    Try display the HttpContext.Current.Session.SessionID to determine whether you are in the same session in all cases.

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

Sidebar

Related Questions

I am using Datagridview in asp.net. I have used custom buttons of up and
I have made a custom class extending Preferences. I have used that custom class
I’ve used the asp.net login control on my sharepoint custom master page. All works
I have built a custom membership provider that I have used in a previous
I have created my custom MembershipProvider. I have used an instance of the class
I came across some code recently that used a custom error handler to turn
What kind of things have you used custom .NET attributes for in the real
We have used Custom List View inside that one Text View and two Edit
I have implemented some component. I used jsp custom tags. But I've implemented 2
I have used custom cell class for my uitableview and used in cellForRowAtIndexPath method.

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.