Replacing or improving Session vars usage - advice

L

Larry Neylon

Hi,

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
users.

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
persistence.

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,
Larry.
 
A

Anthony Jones

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.,
'/myFolder/mySubFolder/myPage.asp'

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).

Anthony.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top