470,815 Members | 1,186 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

Replacing or improving Session vars usage - advice


I'm working on a VBScript application on IIS6 and I'm looking for some
advice about the best way of replacing or improving session variable usage.

The application is in a secure extranet environment. Currently the
application has a search customers page with 10 search fields which list the
results below the search fields. The requirement for this screen was that
the user could return to this result page at any point from any page in the
application and see his last set of results.

As a quick fix I used session variables to store the search values and
loaded them into the search page upon return. Works fine and didn't worry
me too much about using 10 session vars.

Now the users want similar functionality on all search screens (another 6)
giving me a potential of 60 session variables for search results (on top of
about another 10 legacy session vars).

Suddenly I am worried about 70 session variables, potentially containing
reasonably long strings, with a 2 hour session timeout for a potential 1000

What would people recommend I do to either replace the session variables or
improve performance of them.

My thoughts are:

1. Store in the database alongside the user record. I'm already retrieving
the user record on most pages so it would be a case of getting the extra 60
fields from the DB when required. Would also provide cross session result

2. Cookies. Have only ever used sparingly. Would this be too much data
for storing in cookies ? Any performance trade-off ?

3. Store an array/arrays in fewer session variables. Each search result
page could just have one session variable with an array of all the search
field values for that page. Would one session variable containing an array
be much better than 10 session variables ?

4. Just use the 70 session variables and stick more memory in the server if
we get issues. Probably the cheapest and easiest solution, though not the
right one I'm sure.

Any advice would be much appreciated as I'm kind of at the limit of what I
know about performance issues.

Many thanks,
Feb 22 '06 #1
1 1823
Store the values in the database.
Rather than inventing a field for each value use XML.

Create a User Config table with the fields (I'm using SQL Server parlance)

UserID int, Key varchar(512), XML ntext

When a page receives the search request it can create an XML DOM and store
the values in the XML:-
Dim oDOM

Set oDOM = Server.CreateObject("msxml2.DOMDocument.3.0")

oDOM.loadXML "<config />"

AddElem oDOM, "myField", Request.Form("myField")


Function AddElem(parent, name, value)

Set AddElem = parent.createElement(name)

If Not IsNull(value) Then
AddElem.Text = CStr(value)
End If

End Function
The user choices can then be saved from oDOM.xml property in the UserConfig
table. I use the the page URL as a key e.g.,

When the user revisits the page you use the UserID and the page URL to fetch
an XML string that you can then load an XML DOM with. You can subsequently
retrieve the values for the fields from the XML.

This approach is memory efficient and survives cross sessions (potentially
allowing you to drop the session timeout).

Feb 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by james | last post: by
8 posts views Thread by chotiwallah | last post: by
8 posts views Thread by ndsoumah | last post: by
3 posts views Thread by Mark | last post: by
5 posts views Thread by VB Programmer | last post: by
1 post views Thread by Mike McDonald | last post: by
5 posts views Thread by Terry On Windigo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.