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. Advertising

  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. Advertising

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:
    949
  2. SaravanaKumar
    Replies:
    6
    Views:
    9,449
    Tony Morris
    Oct 19, 2004
  3. bugbear
    Replies:
    4
    Views:
    450
    bugbear
    Aug 23, 2006
  4. Robin
    Replies:
    0
    Views:
    428
    Robin
    Jun 6, 2007
  5. Hicham Mouline
    Replies:
    5
    Views:
    2,403
    James Kanze
    Dec 19, 2008
Loading...

Share This Page