Session variables and Arrays 
Author Message
 Session variables and Arrays

Hi people,

I've been on this little piece of code all day, and I can't find out why it
doesn't work.

(IIS 3, ASP1)
Here's the code:
----------------------------------------------------------------------------
---
dim iStep
dim iNextStep
dim oForm

If Request.ServerVariables( "REQUEST_METHOD" ) = "POST" Then
 Set oForm = Request.Form
Else
 Set oForm = Request.QueryString
End If

' aNextStep( ) array defined on beforehand (not included -> works fine)
iStep = oForm( "step" )
iNextStep = aNextStep( iStep )

' Everything works until here.
Session( "formvars" ) = Array( "_dummy" )
Dim sItem
Dim aTemp
For Each sItem In oForm
 If LCase( Left( sItem, 1 ) ) = "q" Then
  aTemp = Session( "formvars" )
  ' The next line fails: Type mismatch.
  aTemp( sItem ) = oForm( sItem )
  Session( "formvars" ) = aTemp
 End If
Next

----------------------------------------------------------------------------
-------
I've tried several approaches.
I used Request.Querystring or Request.Form directly instead of the oForm
construct. Same problem.
I tried with a temporary array (like in the code above) or without one. Same
problem.
Even doing:
Session( "formvars" )( "dummy ") = "dummy" gives a type mismatch.

Can't i have arrays in Session variables?

What I want is this:
There are several forms following each other, each asking the user some
questions. I want every answer to be recorded in the Session so that I can
calculate a score at the end. I could go iterating over each specific value
but I want to do it automatically: each variable that begins with 'q' should
be processed at the end.
Storing the 'qX' values directly into the Session works, but how can i get
them back out? This code doesn't do it:

----------------------------------------------------------------------------
-------
Dim iScore

iScore = 0
For Each sItem In Session
  Response.Write "sItem=" & sItem & "<BR>"
Next
----------------------------------------------------------------------------
-------

ASP1 doesn't seem to know about Session.Contents, so that's to no avail
either.

*sigh*
any help?

Tom.

(Does anyone know a good resource about ASP 1 on IIS 3?)



Sun, 18 Feb 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Session Variables and Arrays

2. Passing Array to Session Variable Then back to Array

3. Splitting Session Variable into several variables (array?)

4. ASP - Array in Session Variable ? (JScript)

5. Storing JScript Arrays in a Session Variable

6. storing a 2 dimensional array in a session variable

7. Multi-dimentional Arrays in Session Variables?

8. Help! Storing Arrays in Session Variables - problem

9. How can I use an array as variable Session

10. Create a dynamic array from set of Session variables

11. Session("Variable") as Array ...ASP

12. Storing arrays in a Session Variable

 

 
Powered by phpBB® Forum Software