To save trips to sql db in my older apps, I store *dozens of data points about the current user in an array and then store the array in a session. For example, info that might be used repeatedly during user’s session might be stored…
Dim a(7) as string
a(0) = “FirstName”
a(1) = “LastName”
a(2) = “Address”
a(3) = “Address2”
a(4) = “City”
a(5) = “State”
a(6) = “Zip”
session.add(“s_a”, a)
*Some apps have an array 100 in size.
That is something I learned in my asp classic days. Referencing the correct index can be laborsome and I find it difficult to go back and add another data point in the array grouped with like data. For example, suppose I need to add Middle Initial to the array as a design alteration. Unless I redo the whole index mapping, I have to stick Middle Initial in the next open slot, which might be in the 50s.
NOW, I am considering doing something easier to reference each time (eliminating the need to know the index of the value wanted). So I am looking to do this…
session.add(“Firstname”, “FirstName”)
session.add(“Lastname”, “LastName”)
session.add(“Address”, “Address”)
etc.
BUT, before I do this, I would like some guidance. I am afraid this might be less efficient, even though easier to use. I don’t know if a new session object is created for each data point or if there is only one session object, and I am adding a name/value pair to that object?
If I am adding a name/value pair to a single object, that seems like a good idea. Does anyone know? Or is there a more preferred way? Built-in Profile class?
Re: Profile class
I have an internal debate about scope.
It seems that the .net Profile class is good for storing app-SPECIFIC user settings (i.e. style theme, object display properties, user role, etc.) The examples I give are information whose values are selected/edited by the user to customize the application experience. This information is not typically stored/edited elsewhere in the app db.
But when you have data that 1) is stored already in the app db and 2) can be altered by other users (in this case: company reps may update client's status, address, etc.), then the persistence of the Profile data may be an issue. In this case, the Profile would need to be reset at the beginning and dropped like a session.abandon at the end of each user's session to prevent reloading info that had since been edited by someone. I believe this is possible, but not sure
Currently, I use the session array to store both scopes, app-specific and user-specific data.
If my session plan is good, I think I will create a class to set/get values from the session also. I appreciate your thoughts. I would like to know how others have handled this type of situation. Thanks.