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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping State With Session Variables 1

Status
Not open for further replies.

Kenjan

Programmer
Mar 4, 2003
13
US
First, I'm new to ASP so I may be asking something that seems obvious.

Background:
I'm working on a small ASP application that keeps track of state using session variables. The session variables contain objects that belong to a VB6 dll library. There are not any connections to a database. The objects create an XML file that will be parsed by another dll at a later time and imported into a database.

Question:
I'm concerned about having session variables that contain objects.

Which is better?:
1)To have a couple of hundred session variables that you load into an object at the end of your session.

2)To have one session variable that contains a couple of hundred properties that you carry around.

All comments/help is appreciated!
 
To have a bunch of session variables w/ data inside them is good. It is never a good idea to put an object in a session variable though.

-Bad Dos
 
I would consider moving to something other than session variables, however. Session variables use RAM for storage, so bogging down with a lot of data when a few users hit the site is entirely possible. Especially if the sessions onEnd doesn't fire and all of them are waiting for the 10 minute timeout.

As a sidenote, MS did states using form inputs an javascript in ASP.Net.

-Tarwn [sub]01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101 [/sub]
[sup]29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19[/sup]
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
How do you handle keeping state for multiple items? Such as vehicle information for multiple vehicles or contact information for multiple people.

I'm guessing most people just write the info to the DB each time a new person or vehicle is entered instead of trying to keep the state for each instance.
 
It depends. If this is information you want to keep for long-term storage or you want to match against data in the databse, then I would go with a database entry and simply store the primary key to that entry in a session variable or form value. If it is a great deal of info, I would again go the route of storing it in the db.
The positive points to this are:
1) Dbs are made for data storage
2) You can make queries easier by simply crossing or joining the users entry in that table with other tables you need info from for that user
3) You can save the user data for them and allow them to acces it in a later session
4) You don't have to worry about remembering 10 or 20 session variable or form input names, just the one that has the record key.

-Tarwn [sub]01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101 [/sub]
[sup]29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19[/sup]
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top