Reading/Writing Session variables from a Static class

Discussion in 'ASP .Net' started by aliendolphin@gmail.com, Jan 25, 2005.

  1. Guest

    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
     
    , Jan 25, 2005
    #1
    1. Advertisements

  2. On 1/25/2005 3:02 PM, 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
     
    Craig Deelsnyder, Jan 26, 2005
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    1,141
  2. SaravanaKumar
    Replies:
    6
    Views:
    9,929
    Tony Morris
    Oct 19, 2004
  3. E11
    Replies:
    1
    Views:
    5,790
    Thomas Weidenfeller
    Oct 12, 2005
  4. bugbear
    Replies:
    4
    Views:
    660
    bugbear
    Aug 23, 2006
  5. Kevin Walzer
    Replies:
    6
    Views:
    568
  6. Robin
    Replies:
    0
    Views:
    568
    Robin
    Jun 6, 2007
  7. Neviton
    Replies:
    9
    Views:
    662
    Alf P. Steinbach
    Sep 17, 2007
  8. Hicham Mouline
    Replies:
    5
    Views:
    2,741
    James Kanze
    Dec 19, 2008
Loading...