Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions Information

Status
Not open for further replies.

crystalized

Programmer
Jul 10, 2000
390
CA
Hello All,

I know this was always a hot topic of discussion on the asp forum but I could not find any threads discussing it in this forum.

So here is my question. What is the better route to take, I have a user object. I could either just have properties in the object that get and set individual session variable values, or I could instantiate the user object and keep it in the session.

The user object does not have a huge number of properties and some of them may be blank or null. It does not contain any arrays or other complex data structures all the properties are strings, bytes or boolean values.

So part of me thinks that it is more understandable to create the user object and keep it in the session as a complete entity, but the other part of me sees that as a potential memory hog, especially since some of the properties will be blank or unused in a number of the user instances.

Any thoughts or words from experience on this topic would be greatly appreciated.
Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Hey Crystal,

It's better to create the entire object. The whole idea of objects is to encapsulate the properties, as well as any methods that may be in use. Since web apps are usually seen as n-tiered, keeping the entire object also means less code on your page and more hidden away. Also, you won't have to keep track of all those session variables
:)

One other thing to think about is when to use an object. The way our application is set up, we hardly ever keep an object over pages. We usually just create the object to either get data, manipulate data, do some sort of function, etc., then destroy it. In this way, you get the best of both worlds: object oriented benefits with proper server utilization.

of course, one object in a session over a page or two shouldn't kill your app. Bottom line: I'd keep the object.

But thats just me
:)

Jack
 
Jack,

Thanks a bunch for your input. I was certainly leaning toward the object route but was not feeling very sure.

One thing I have certainly decided is that I am going to try and trim some of the "fat" off of my object. I was adding information that is not likely to be used on a regular basis between pages, so I think I will just try and trim it down a bit. Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top