Use Session or not?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • r

    Use Session or not?

    Hello all
    I have a website that each user has it's profile.
    I use Session object for having their states for example the user has logged
    on or not..
    Is there a better way to do this?
    thanks in advance


  • Mark Rae [MVP]

    #2
    Re: Use Session or not?

    "r" <rezarms@hotmai l.comwrote in message
    news:eiin4AINJH A.2884@TK2MSFTN GP06.phx.gbl...
    I have a website that each user has its profile.
    I use Session object for having their states for example the user has
    logged on or not..
    Is there a better way to do this?
    I don't think so - the Session object is ideal for persisting user-specific
    metadata...


    --
    Mark Rae
    ASP.NET MVP


    Comment

    • my cats, Gag and yak

      #3
      Re: Use Session or not?


      Regarading Session variables, some things can cause session values to go
      away, Application_Err or firing is an example.

      try something like the following to work around Session variables being
      volatile:

      string key = "abc";
      bool GetCookie = false;

      try
      {
      if (HttpContext.Cu rrent == null)
      {
      GetCookie = true;
      }
      else
      {
      if (HttpContext.Cu rrent.Session[key] == null)
      {
      GetCookie = true;
      }
      }

      if (GetCookie)
      {
      Read the cookie to get CookieValue
      HttpContext.Cur rent.Session[key] = CookieValue;
      }
      else
      {
      ValueToReturn = HttpContext.Cur rent.Session[key].ToString();
      }
      }



      regarding controling logins, create a process to understand when a visitor
      has logged in, and another that understands when they have been gone too
      long. Use something like ( google for ) Defibrillator though it refreshes
      session, connect the dots from that to using a process to update your DB.


      John Bickmore




      "Mark Rae [MVP]" <mark@markNOSPA Mrae.netwrote in message
      news:u7VD$VINJH A.2044@TK2MSFTN GP04.phx.gbl...
      "r" <rezarms@hotmai l.comwrote in message
      news:eiin4AINJH A.2884@TK2MSFTN GP06.phx.gbl...
      >
      >I have a website that each user has its profile.
      >I use Session object for having their states for example the user has
      >logged on or not..
      >Is there a better way to do this?
      >
      I don't think so - the Session object is ideal for persisting
      user-specific metadata...
      >
      >
      --
      Mark Rae
      ASP.NET MVP
      http://www.markrae.net

      Comment

      • sloan

        #4
        Re: Use Session or not?

        You use it, but frugally.

        A small profile object is fine.

        8GB of "Report Data"....is too heavy.

        ...........



        "r" <rezarms@hotmai l.comwrote in message
        news:eiin4AINJH A.2884@TK2MSFTN GP06.phx.gbl...
        Hello all
        I have a website that each user has it's profile.
        I use Session object for having their states for example the user has
        logged on or not..
        Is there a better way to do this?
        thanks in advance
        >

        Comment

        Working...