T
TRB_NV
I'm losing information from my Session when I change pages or start the same
page over again. I simplified the code so the example is really clear. The
sample code that follows is supposed to generate a random number and put it
into an Array and store it in the Session variable and then when it runs the
next time, generate another random number and display the entire Array
contents, by pulling the information out of the Session. I'd greatly
appreciate someone with fresh eyes taking a look at this code. Thanks.
<%@ LANGUAGE="VBSCRIPT" %>
<%
if Request.Form("clear") = "true" then
Session.Contents.Remove("ShoppingCart")
Session("ItemCount") = 0
clearcart = ""
end if
dim cart(999,9)
Randomize Timer
r1 = Rnd
r1 = r1 * 1000000
intOrderID = 1000000 + Int (r1)
intItemCount = Session("ItemCount")
if intItemCount = 0 then
intItemCount = 1
Session("ItemCount") = intItemCount
else
intItemCount = intItemCount + 1
Session("ItemCount") = intItemCount
end if
Session("ItemCount") = intItemCount
cart(intItemCount,1)=intOrderID
Session("ShoppingCart")=cart
xcart=Session("ShoppingCart")
for x = 1 to intItemCount
response.write x & " " & xcart(x,1) & "<br>"
next
%>
<form action="array.asp" method="post">
<input type="hidden" name="clear" value="true">
<input type="Submit" name="Submit" value="Clear Shopping Cart">
</form>
<form action="array.asp" method="post">
<input type="hidden" name="clear" value="false">
<input type="Submit" name="Submit" value="Reload">
</form>
page over again. I simplified the code so the example is really clear. The
sample code that follows is supposed to generate a random number and put it
into an Array and store it in the Session variable and then when it runs the
next time, generate another random number and display the entire Array
contents, by pulling the information out of the Session. I'd greatly
appreciate someone with fresh eyes taking a look at this code. Thanks.
<%@ LANGUAGE="VBSCRIPT" %>
<%
if Request.Form("clear") = "true" then
Session.Contents.Remove("ShoppingCart")
Session("ItemCount") = 0
clearcart = ""
end if
dim cart(999,9)
Randomize Timer
r1 = Rnd
r1 = r1 * 1000000
intOrderID = 1000000 + Int (r1)
intItemCount = Session("ItemCount")
if intItemCount = 0 then
intItemCount = 1
Session("ItemCount") = intItemCount
else
intItemCount = intItemCount + 1
Session("ItemCount") = intItemCount
end if
Session("ItemCount") = intItemCount
cart(intItemCount,1)=intOrderID
Session("ShoppingCart")=cart
xcart=Session("ShoppingCart")
for x = 1 to intItemCount
response.write x & " " & xcart(x,1) & "<br>"
next
%>
<form action="array.asp" method="post">
<input type="hidden" name="clear" value="true">
<input type="Submit" name="Submit" value="Clear Shopping Cart">
</form>
<form action="array.asp" method="post">
<input type="hidden" name="clear" value="false">
<input type="Submit" name="Submit" value="Reload">
</form>