|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to create and use a session variable
Hi,
I have the following code which works for a page: Code:
dim lcount, qlist, tlist, dlist, rlist ,llist ,flist, plist , carttotal, icount, price , total
carttotal=0
qlist = Session("qty")
tlist = Session("type")
dlist = Session("diameter")
rlist = Session("rod")
llist = Session("length")
flist = Session("finish")
plist = Session("price")
icount = UBound(qlist)
for lcount = 1 to icount
price = Clng(plist(lcount))
total = CLng(plist(lcount)) * CLng(qlist(lcount))
carttotal=carttotal + total
%>
How do I make "carttotal" a session variable so it can be used on another page in the folloing bit of code: Code:
<%=FormatNumber(carttotal, 2, -2, -2, 0)%>
<%Session("cost")=FormatNumber(carttotal, 2, -2, -2, 0)%>
and how would the 2nd part of code change? Many thanks in advance, Janusz
__________________
http://www.xlibris.co.uk http://janusz.monkey-it.co.uk |
|
#2
|
|||
|
|||
|
Unless I'm missing something obvious, use
Session("carttotal") = carttotal in the first page carttotal = Session("carttotal") in the 2nd page |
|
#3
|
|||
|
|||
|
D'oh
So how would both sets of code now look? I've tried what you suggested but it dont work, maybe I coded it wrong.
Janusz |
|
#4
|
|||
|
|||
|
First page now looks like:
Code:
<%
dim lcount, qlist, tlist, dlist, rlist ,llist ,flist, plist , carttotal, icount, price , total
carttotal=0
qlist = Session("qty")
tlist = Session("type")
dlist = Session("diameter")
rlist = Session("rod")
llist = Session("length")
flist = Session("finish")
plist = Session("price")
carttotal = Session("carttotal")
icount = UBound(qlist)
for lcount = 1 to icount
price = Clng(plist(lcount))
total = CLng(plist(lcount)) * CLng(qlist(lcount))
carttotal=carttotal + total
%>
Second page looks like: Janusz Code:
<%=FormatNumber(Session("carttotal"), 2, -2, -2, 0)%>
But it still won't show the price on the second page! Janusz |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > How to create and use a session variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|