Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use session  RSS feed

 
David Spades
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to go back to basic and strengthen some of my foundation. I'm wondering what kind of data would be appropriate to be stored inside a session? My app is a web app where all the users are the employee of a company. So it's an web-based app that keeps track of stock movements, purchasing and sales order (standard distributor company). The web app interacts strictly with employees, so no public facing app (yes, that's right, no shopping cart). So, in this kind of web app, what kind of data that by storing it to session would be good practice and why? thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember two important aspects to the session:
  • It is specific to one user usng one specific browser.
  • Values placed in the session have a scope that lasts across requests, until the session expires or is destroyed.

  • So the answer isn't very specific to an app type, but to how the data should be scoped. Data specific to a single user that needs to survive across requests is a candidate for the session. Other data, not so much.
     
    William Brogden
    Author and all-around good cowpoke
    Rancher
    Posts: 13078
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It is also important to note that severs are allowed to serialize a session to disk any time they want. A serialized session object will contain serialized versions of all objects it has references to.

    Therefore, any object references you want to keep in a session must refer to a Serializable object or you will be setting yourself up for hard to understand errors.

    Bill
     
    David Spades
    Ranch Hand
    Posts: 348
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    so, in real world application (excluding shopping cart), any example of such data where it's necesssary to preserve it over several requests? up until now, I haven't encountered such case. thanks
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!