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!

session problem

Status
Not open for further replies.

joakimhan

Technical User
Jul 9, 2001
12
SE

I found this code for storing info in a session.

<%
option explicit
dim isbn, aCart(100), iLoop
isbn = Request.QueryString(&quot;isbn&quot;)

'Initialize aCart with contents of session variable
If IsArray(Session(&quot;cart&quot;)) then
For iLoop = 0 to Session(&quot;cart&quot;)(0)
aCart(iLoop)= Session(&quot;cart&quot;)(iLoop)
Next
else
' no Session variable yet. Initialize item counter.
acart(0)=0 'counter for number of items in cart
end if

If Request.QueryString(&quot;action&quot;) = &quot;add&quot; then
'add new item to aCart
if len(isbn) > 0 then
acart(0)=acart(0)+1
aCart(acart(0)) = isbn
end if
elseif Request.QueryString(&quot;action&quot;) = &quot;del&quot; then
'replace the deleted item with the item above it
For iLoop = Request.QueryString(&quot;item&quot;) to acart(0)-1
acart(iLoop) = acart(iLoop+1)
Next
acart(0) = acart(0)-1
end if

' show content of shopping cart
Response.write &quot;Items in shopping cart = &quot;& aCart(0) &&quot;<br>&quot; For iLoop = 1 to aCart(0)
Response.write iLoop &&quot;. ISBN =&quot;& aCart(iLoop) &_
&quot; <a href='order_view.asp?item=&quot;& iLoop &&quot;&action=del'> Remove</a><br>&quot; Next

' update session variable
Session(&quot;Cart&quot;) = aCart

%>

My problem is that I want to store 2 variables, isbn and Titel. Do anyone know how to modify this code.

Best Regards
Joakim
 
U need to add in the initialization part in your global.asa file
Code:
global.asa

Sub Session_OnStart
  Dim Session(&quot;var1&quot;)()'an array
  Dim Session(&quot;var2&quot;)
'and so...
end Sub

Sub Session_OnEnd
  set Session(&quot;var1&quot;)=nothing
  set Session(&quot;var2&quot;)=nothing
'and so...
end Sub

and in your asp file
MyFile.asp
<%
Redim Session(&quot;var1&quot;)(10)
Session(&quot;var1&quot;)(0)=&quot;val1&quot;
'and so
Session(&quot;var1&quot;)(9)=&quot;val9&quot;

Session(&quot;var2&quot;)=&quot;MyValue&quot;
%>
________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top