Forum Moderators: open

Message Too Old, No Replies

Help! Can't figure out way to pass session variables

         

dickbaker

10:39 pm on Jun 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an off-the-shelf shopping cart, and I'd like to have the ability to show the cart contents (item, price, number of items) on every .asp page on the site.

The shopping cart comes with a minicart page with the script written. It works exactly as it should when moving from page to page in the SSL section of the site. On non-secure (http://) pages, though, the contents of the shopping cart are not updated. It's not passing the variables from the SSL side to the non-SSL.

Is there a script I can write to get the values of the cookie that's generated by this script, and put that cookie script in the non-SSL pages?

Below is the entire minicart script. Any help is much appreciated.

************

if Trim(Request.Form("sessionid")) <> "" then thesessionid = replace(trim(Request.Form("sessionid")), "'", "") else thesessionid = Session.SessionID
if NOT isnumeric(thesessionid) then thesessionid=-1
function FormatMCCurrency(amount)
if overridecurrency=true then
if orcpreamount=true then
FormatMCCurrency = orcsymbol & FormatNumber(amount,orcdecplaces)
else
FormatMCCurrency = FormatNumber(amount,orcdecplaces) & orcsymbol
end if
else
if useEuro then
FormatMCCurrency = FormatNumber(amount,2) & " &euro;"
else
FormatMCCurrency = FormatCurrency(amount)
end if
end if
end function
mcgndtot=0
mcpdtxt=""
totquant=0
shipping=0
discounts=0
if session("xscountrytax")<>"" then xscountrytax = cDbl(session("xscountrytax")) else xscountrytax=0
Set rs = Server.CreateObject("ADODB.RecordSet")
Set rs2 = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
if incfunctionsdefined=TRUE then
alreadygotadmin = getadminsettings()
else
sSQL = "SELECT countryLCID,countryCurrency,adminStoreURL FROM admin INNER JOIN countries ON admin.adminCountry=countries.countryID WHERE adminID=1"
rs.Open sSQL,cnn,0,1
if orlocale<>"" then
Session.LCID = orlocale
elseif rs("countryLCID")<>0 then
Session.LCID = rs("countryLCID")
end if
useEuro = (rs("countryCurrency")="EUR")
storeurl = rs("adminStoreURL")
if (left(LCase(storeurl),7) <> "http://") AND (left(LCase(storeurl),8) <> "https://") then storeurl = "http://" & storeurl
if Right(storeurl,1) <> "/" then storeurl = storeurl & "/"
rs.Close
end if
if request.form("mode")="checkout" then
if trim(request.form("checktmplogin"))<>"" AND isnumeric(trim(request.form("sessionid"))) then
sSQL = "SELECT tmploginname FROM tmplogin WHERE tmploginid=" & replace(trim(request.form("sessionid")),"'","") & " AND tmploginchk=" & replace(trim(request.form("checktmplogin")),"'","")
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then Session("clientID")=rs("tmploginname")
rs.Close
else
Session("clientID")=empty
end if
end if
sSQL = "SELECT cartID,cartProdID,cartProdName,cartProdPrice,cartQuantity FROM cart WHERE cartCompleted=0 AND " & getsessionsql()
rs2.Open sSQL,cnn,0,1
do while NOT rs2.EOF
optPriceDiff=0
mcpdtxt = mcpdtxt & "<tr><td class=""mincart"" bgcolor=""#F0F0F0"">"&rs2("cartQuantity") &" " & rs2("cartProdName") & "</td></tr>"
sSQL = "SELECT SUM(coPriceDiff) AS sumDiff FROM cartoptions WHERE coCartID="&rs2("cartID")
rs.Open sSQL,cnn,0,1
if NOT IsNull(rs("sumDiff")) then optPriceDiff=rs("sumDiff")
rs.Close
subtot = ((rs2("cartProdPrice")+optPriceDiff)*Int(rs2("cartQuantity")))
totquant = totquant + Int(rs2("cartQuantity"))
mcgndtot=mcgndtot+subtot
rs2.MoveNext
loop
rs2.Close
cnn.Close
set rs = nothing
set rs2 = nothing
set cnn = nothing
%>
<table class="mincart" width="130" bgcolor="#FFFFFF">
<tr>
<td class="mincart" bgcolor="#F0F0F0" align="center"><img src="images/littlecart1.gif" align="top" width="16" height="15" alt="<%=xxMCSC%>" />
&nbsp;<strong><a class="ectlink mincart" href="<%=storeurl%>cart.asp"><%=xxMCSC%></a></strong></td>
</tr>
<%if request.form("mode")="update" then %>
<tr><td class="mincart" bgcolor="#F0F0F0" align="center"><%=xxMainWn%></td></tr>
<%else %>
<tr><td class="mincart" bgcolor="#F0F0F0" align="center"><%=totquant & " " & xxMCIIC %></td></tr>
<%response.write mcpdtxt
if mcpdtxt<>"" AND session("discounts")<>"" then
discounts = cDbl(session("discounts")) %>
<tr><td class="mincart" bgcolor="#F0F0F0" align="center"><font color="#FF0000"><%=xxDscnts & " " & FormatMCCurrency(discounts)%></font></td></tr>
<%end if
if mcpdtxt<>"" AND session("xsshipping")<>"" then
shipping = cDbl(session("xsshipping"))
if shipping=0 then showshipping="<font color=""#FF0000""><strong>"&xxFree&"</strong></font>" else showshipping=FormatMCCurrency(shipping) %>
<tr><td class="mincart" bgcolor="#F0F0F0" align="center"><%=xxMCShpE & " " & showshipping%></td></tr>
<%end if
if mcpdtxt="" then xscountrytax=0 %>
<tr><td class="mincart" bgcolor="#F0F0F0" align="center"><%=xxTotal & " " & FormatMCCurrency((mcgndtot+shipping+xscountrytax)-discounts)%></td></tr>
<%end if %>
<tr><td class="mincart" bgcolor="#F0F0F0" align="center"><font face='Verdana'>&raquo;</font> <a class="ectlink mincart" href="<%=storeurl%>cart.asp"><strong><%=xxMCCO%></strong></a></td></tr>
</table>

dickbaker

2:52 am on Jun 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Never mind, I found a simple work-around. Couldn't see the forest for the trees.

marcel

6:26 pm on Jun 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi dickbaker,

I'd love to know how you managed this, I am currently updating/reworking a legacy ASP intranet site, which the customer wants to 'convert' to Internet with an SSL connection.

Classic ASP is definitely not my strong point, so any help would be apreciated.