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

creating a session variable from array

Status
Not open for further replies.

paulh1111

Technical User
Jun 9, 2003
19
US
I have a multi-dimensional array, that I would like to create a session variable so I can use it in different asp pages.

I've tried just session(Array())
but that doesn't seem to work

thanks.
Paul
 
you want the entire array assinged to one session value? or just one value from the array? ( secondly session(array()) wont work you need to assing a name and value to session )

like Session("firstname") = "joe"

or session("firstname") = ArrayVar(2)

 
I'm trying to create a shopping cart, so I want the all values in the array to be assigned to a session. My first asp page populate the multi-dim.. array.
So I have values in array, i.e. array(0,0) = name
array(0,1) = description
array(0,5) = image info (you helped me previously with that)

so in some later asp pages, i would like to refernce those values individually again. i.e. array(0,3)

I hope that makes sense.
thanks paul
 
hmmmm
perhaps it would be alot easier ( in mind and implementation ) to use a 'garbage' table, basically make a table to hold session values, then use the session("sessionid") to query it, then you can have a multitude of rows that you can retrieve ( and using getrows, pass it right back into an array mind you ) versus cluttering up the server memory with possibly large session values

but in answer to the question ...

Assigning :

Session("MyArray") = ArrayVar ' no quotes or anything pass the whole array to it


Fetching :

Dim MyVar
MyVar = Session("MyArray")

' not used to using this methodology you may have to use the following line to make it accept it properly

MyVar = Array(Session("MyArray")

but i would highly recommend using a temp values table .. or dumping the info to cookies, that way should the user accidentally close a window ( or have something like a popupkiller that somehow a product makes the page close ) that they dont lose all session info

 
Well eventually all this data will go into a table. I wish i had used tables from the begining, but i have spent so much time on multi-dimensional arrays, and populating them and then displaying them, that i would hate to do something different. You can take a look at
It isn't quite fully functional yet, but i'm getting there. one of my last steps is to do an order conformation page, sumerise everything ordered in shopping cart and then transfer data to access table.
Any other advise will be appreciated,
thanks
 
[smile] uhm put the shopping cart contents into a DB table ?

there's also a FAQ about adding a shopping cart under ASP 102 in the FAQ's section here that might help a little.
 
Ok lets say you have myArray variable already filled as you told.

firstfile.asp

myArray(...)=...
....

set Session("myArray")=myArray ' this line should store the myArray into session

secondfile.asp

myArray=Session("myArray")
'now you can use myArray same as any other array


________
George, M
 
and thread333-554571

____________________________________________________
[sub]The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-2924[/sub]
onpnt2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top