473,614 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading/Writing Session variables from a Static class

I'm having a strange problem possibly with Session variables for one
user being accessed by another.

I use a static utility class with static methods which get and set
certain Session variables. For Example:

public static string UserEmail
{
get { return HttpContext.Cur rent.Session["email']; }
set { HttpContext.Cur rent.Session["email"] = value; }
}

But, user A making this call was able to get back the email session
object for user B.

I would think that no matter how many users are using the static class,
they all get and set their own session variable "email".
Since I'm not storing the Session info in the static method but just
grabbing it. This should work, right?

Thanks

Nov 19 '05 #1
1 3759
On 1/25/2005 3:02 PM, al**********@gm ail.com wrote:
I'm having a strange problem possibly with Session variables for one
user being accessed by another.

I use a static utility class with static methods which get and set
certain Session variables. For Example:

public static string UserEmail
{
get { return HttpContext.Cur rent.Session["email']; }
set { HttpContext.Cur rent.Session["email"] = value; }
}

But, user A making this call was able to get back the email session
object for user B.

I would think that no matter how many users are using the static class,
they all get and set their own session variable "email".
Since I'm not storing the Session info in the static method but just
grabbing it. This should work, right?

Thanks


Don't have an answer, but yes it should. I've done this before myself,
where you're creating a 'session utility' class....

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
42016
by: Wayne | last post by:
Hi, I'm new to .NET and have a question about the use of static variables vs. session variables in a web form in C#. Instead of using a session variable to hold a string to persist during datagrid paging. Can I use a static variable? Also, if I use a static variable is that variable shared by everyone that brings up the aspx page? Ex, if 4 people are viewing the aspx page is an instance of the static variable created for each of the...
2
1695
by: adam | last post by:
Having spent nearly 2 years in win forms land the inevitable request came for me to "do some web pages". So being new to this bit of .net and having had a look around I can't see where the best way to store session data. 1) use the (string)Session approach Obviously bad for maintenance, readability etc. 2) have a typed MySession object with static properties for each value I want to store
6
1263
by: Just D | last post by:
Hi, How slowly is to work with these objects - Application and Session ? Is it much better to create a huge project or some static library and place all variables/constants there instead of many Session objects? When I removed some of Session objects and replaced by another approaches I got an illusion that application started working significantly faster? Is it true?
15
2502
by: Jason | last post by:
Currently, I am storing information about the currently logged on user in Session variables that are stored in SQL. However, I am using role-based security, so I am storing custom roles in a GenericPrincipal object that I attached to Context.User. My question is this: Can I create a new class, ExtendedPrincipal for instance, and simply inherit System.Security.Principal and store all of the information currently stored in Session...
9
3181
by: Randy | last post by:
Hello, I'm having a strange problem. I've got a .NET web app which uses Session variables. Sometime, not all the time, they get cross threaded...that is...one user will have another user's Session variable(s) data assigned to them. I can't figure out why. I've read that other people are having this problem too but I haven't found a resolution yet. Can someone please tell me how I might go about fixing this? Thanks
2
2241
by: james | last post by:
Hi I am considering storing my session variables within one static object with session scope. The static object will be a class with accessor functions to get and set the equivalent session variables stored as member variables. This will allow strong typing. Apart from the problems of multithreading, are there any performance overheards of which I should be aware? Thanks
1
1613
by: cobus.lombard | last post by:
I have found it very easy to have a Helper class that has static members which access Session Variables. For example: public class HelperClass { public static doCustomer CurrentCustomer { get { if(HttpContext.Current.Session == null)
18
3428
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that File-New-Window creates an instance of IE in the same process with the same SessionID as the parent window is in big trouble. This fundamentally restricts the usefullness of using session state management. I probably missed it somewhere - can...
0
5008
by: bharathreddy | last post by:
Here I will given an example on how to access the session, application and querystring variables in an .cs class file. Using System.Web.HttpContext class. 1) For accesing session variables : System.Web.HttpContext.Current.Session 2) For accesing Application variables : System.Web.HttpContext.Current.Application 3) For accesing QueryString variables : System.Web.HttpContext.Current.Request.QueryString Here is a simple example where...
0
8182
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8130
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8627
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8279
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7093
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5540
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4127
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1425
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.