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

Array session problem

Status
Not open for further replies.

johnbell

Programmer
Aug 3, 2000
1
0
0
MY
ASP code page 1<br>===============<br>&lt;%<br><br>Dim prodid, quantity, arrCart, edagangItem<br>prodid = Request.Form(&quot;fproductid&quot;)<br>quantity = Request.Form(&quot;fquantity&quot;)<br>arrCart=Session(&quot;bakul&quot;)<br>edagangItem = Session(&quot;cartItem&quot;)<br><br>If edagangItem = &quot;&quot; Then<br>&nbsp;Response.Redirect &quot;<A HREF=" TARGET="_new"> &<br>Server.URLEncode (&quot;Sila membenarkan cookie pada pelayar anda untuk berurusan<br>e-dagang.&quot;)<br>End If<br><br>If prodid &lt;&gt; &quot;&quot; Then<br>&nbsp;If edagangItem &lt; maxCartItems Then<br>&nbsp;&nbsp;edagangItem = edagangItem + 1<br>&nbsp;End If<br>&nbsp;Session(&quot;cartItem&quot;) = edagangItem<br>&nbsp;Dim rsItem<br>&nbsp;Set rsItem = Server.CreateObject(&quot;ADODB.Recordset&quot;)<br>&nbsp;&nbsp;rsItem.Open &quot;products&quot;, dbc, adOpenForwardOnly,adLockReadOnly,adCmdTable<br>&nbsp;&nbsp;rsItem.Filter = &quot;catalogID = &quot; & prodid<br>&nbsp;If Not rsItem.EOF Then<br>&nbsp;&nbsp;arrCart(cProductid,edagangItem) = rsItem(&quot;catID&quot;)<br>&nbsp;&nbsp;arrCart(cProductCode,edagangItem) = rsItem(&quot;kod&quot;)<br>&nbsp;&nbsp;arrCart(cProductname,edagangItem) = rsItem(&quot;name&quot;)<br>&nbsp;&nbsp;arrCart(cQuantity,edagangItem) = CInt(quantity)<br>&nbsp;&nbsp;arrCart(cUnitPrice,edagangItem) = rsItem(&quot;price&quot;)<br>&nbsp;&nbsp;Session(&quot;bakul&quot;) = arrCart<br>&nbsp;&nbsp;rsItem.Close<br>&nbsp;&nbsp;dbc.Close<br>&nbsp;End If<br>Else<br>Dim strAction<br>strAction = UCase(Left(Request.Form(&quot;action&quot;),5))<br>Select Case strAction<br>&nbsp;&nbsp;&nbsp;&nbsp;case &quot;SAMBU&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;response.redirect &quot;<A HREF=" TARGET="_new"> &quot;HAPUS&quot;<br>&nbsp;&nbsp;&nbsp;response.redirect &quot;<A HREF=" TARGET="_new"> &quot;SIAP &quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Response.Redirect &quot;<A HREF=" TARGET="_new"> Select<br>End If<br>%&gt;<br><br>ASP code Page 2<br>===============<br><br>&lt;%<br>Dim isubtotal, i, edagangItem, arrCart<br>edagangtem=Session(&quot;cartItem&quot;)<br>arrCart=Session(&quot;bakul&quot;)<br>isubtotal = 0<br>For i = 1 to edagangItem<br>%&gt;<br>&nbsp;&nbsp;&lt;tr bgcolor=&quot;#D3D3D3&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input name=&quot;selected&quot; &lt;%= cstr(i)%&gt; type=&quot;checkbox&quot; value=&quot;yes&quot;<br>checked&gt;&lt;%= arrCart(cProductCode,i) %&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;40%&quot;&gt;&lt;%= arrCart(cProductname,i) %&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;input type=&quot;text&quot;<br>name=&quot;quantity&quot; &lt;%= cstr(i) %&gt; value=&quot;&lt;%= arrCart(cQuantity,i) %&gt;&quot;<br>size=&quot;10&quot;&gt;&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;%=<br>FormatCurrency(arrCart(cUnitPrice,i),2) %&gt;&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot; align=&quot;right&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;%=<br>FormatCurrency(arrCart(cUnitPrice,i) * arrCart(cQuantity,i),2)<br>%&gt;&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br>&lt;%<br>&nbsp;isubtotal = isubtotal + (arrCart(cUnitPrice,i) * arrCart(cQuantity,i))<br>&nbsp;Next<br>%&gt;<br><br>My Question<br>==========<br><br>OK, here is my coding for two ASP pages. From ASP page 1, if user type SIAP,<br>the page will redirect to an ASP login page that will validate the username<br>and password. If everything is OK, it will then redirected to ASP page 2.<br><br>The problem that I am facing is session for array cartitem and bakul are not<br>shown in page 2. But it works fine in page 1.<br><br>Please Help.<br><br>Thanks<br><br><br><br><br><br><br><br>
 
Create a custom Object. One property of the object must be the array. Put the Object into the session. This willwork.<br><br>Access with object.Arrayname[count]
 
Um.... no... Don't use the session object to store arrays...
Even microsoft knows that it can cause a gpf when the session expires...
Chad
tinman@thelandofoz.org

Tinman,

Welcome to OZ.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top