Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Reading/Writing Session variables from a Static class

Reply
Thread Tools

Reading/Writing Session variables from a Static class

 
 
aliendolphin@gmail.com
Guest
Posts: n/a
 
      01-25-2005
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.Current.Session["email']; }
set { HttpContext.Current.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

 
Reply With Quote
 
 
 
 
Craig Deelsnyder
Guest
Posts: n/a
 
      01-26-2005
On 1/25/2005 3:02 PM, http://www.velocityreviews.com/forums/(E-Mail Removed) 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.Current.Session["email']; }
> set { HttpContext.Current.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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread safety problems with function scope static variables vs class static private members Hicham Mouline C++ 5 12-19-2008 08:10 PM
Why inner class can not have static data, static fields or nested class? Robin Java 0 06-06-2007 11:16 AM
referring to static fields of enclosing class from static inner class? bugbear Java 4 08-23-2006 08:26 AM
Session Variables and Static Variables cobus.lombard@gmail.com ASP .Net 1 03-26-2006 11:05 AM
Instantiating a static class( Class with all static members - methods and variables) SaravanaKumar Java 6 10-19-2004 08:20 AM



Advertisments