<% '*************************************************************** ' maintains state for VP-ASP using cookies or session variables ' Cookies are not currently supported ' VP-ASP 5.00 May 1, free version ' Free Version '*************************************************************** const CookieKey="VPASP" Sub SetSess (field, value) If getconfig("xUseCookies")<>"Yes" then Session(field)=value else ' debugwrite field & " value=" & value Response.cookies(Cookiekey) (field)=value end if end sub ' Sub SetSessA (field, value) dim a(3) If getconfig("XUseCookies")<>"Yes" Then Session(field)=value exit sub end if dim dataarea, key, keycount,i key = field if ucase(key)="CARTARRAY" then SessSaveCart field, value, cookiekey,1 exit sub end if keycount=ubound(value) dataarea="" for i = 0 to keycount dataarea=dataarea & value(i) & ";" next Response.cookies(Cookiekey) (field)=dataarea end sub ' Function GetSess (field) dim value if getconfig("xUseCookies")<>"Yes" then value=Session(field) Getsess=value else value=Request.cookies(Cookiekey) (field) Getsess=value end if End Function Function GetSessA (field) dim dataarea, temparray(100), tempcount, rc dim value, i, key, cartcount If getconfig("xUseCookies")<>"Yes" then value=Session(field) GetsessA=value exit function end if key = field if ucase(key)="CARTARRAY" then SessRestoreCart field, value, cartcount, CookieKey, rc GetSessA=value exit function end if dataarea=Request.cookies(Cookiekey) (field) If dataarea="" then GetSessA="" exit function end if ParseRecord dataarea, TempArray, tempcount, ";" GetSessA=Temparray End Function Sub SetSessionTimeout If Getconfig("XuseCookies")<>" Yes" then If getconfig("xSessionTimeout")<>"" then Session.timeout=getconfig("xsessiontimeout") end if exit sub end if Response.Cookies(cookiekey).expires = date+1 end sub ' Sub SaveCustomerDetailsCookie Dim cookfield cookfield="" Buildcookie cookfield,"Firstname", strFirstname BuildCookie cookfield,"Lastname", strLastname BuildCookie cookfield,"Address", strAddress BuildCookie cookfield,"City", strCity BuildCookie cookfield,"State", strState BuildCookie cookfield,"PostCode", strPostCode BuildCookie cookfield,"Country", strCountry BuildCookie cookfield,"Company", strCompany BuildCookie cookfield,"Website", strWebsite BuildCookie cookfield,"Phone", strPhone BuildCookie cookfield,"Email", strEmail BuildCookie cookfield,"CustomerID", strCustomerID BuildCookie cookfield,"Custdiscount", strdiscount BuildCookie cookfield,"Customerid", strcustomerid BuildCookie cookfield,"Customertype", strcustomertype Response.Cookies ("CartLogin")=cookfield response.cookies("CartLogin").expires=date()+365 ' debugwrite cookfield end sub Sub BuildCookie (dataarea, fieldname,fieldvalue) If dataarea<>"" then dataarea=dataarea & "," end if If fieldvalue="" then dataarea=dataarea & fieldname & "=" & "???" else dataarea=dataarea & fieldname & "=" & fieldvalue end if end sub Sub RestoreCustomerDetailsCookie dim restored, i dim cookfield, pairs(30),paircount,fields(4), fieldcount ' restored=getsess("Restored") ' if restored<>"" then exit sub cookfield=request.cookies("CartLogin") if cookfield="" then exit sub parserecord cookfield, pairs, paircount,"," for i =0 to paircount-1 parserecord pairs(i), fields, fieldcount,"=" if fields(1)="???" then fields(1)="" end if Setsess fields(0),fields(1) next Session("Restored")="Yes" Session("Login")="Yes" end sub Sub WriteCookie (keyname, dataarea) Response.cookies(Cookiekey) (keyname)=dataarea end sub Sub ReadCookie (keyname, dataarea) dataarea = Request.cookies(Cookiekey) (keyname) end sub Function ShopLcname shoplcname="unused" end function Sub SessSaveCart (field, value, cookiekey, cartdays) dim expires dim cartcount, arrcount, dataarea, j, countkeyname dim keyname dim i dim cartattributes cartattributes=cMaxCartAttributes expires=date+cartdays cartcount=getsess("CartCount") if cartcount="" or cartcount=0 then exit sub 'debugwrite "cartcount=" & cartcount for i = 1 to cartcount dataarea="" for j = 1 to cartattributes dataArea= dataarea & value(j, i) & ";" next keyname= field & cstr(i) ' debugwrite keyname & " " & dataarea & " " & cookiekey Response.cookies(Cookiekey) (keyname)=dataarea Response.cookies(Cookiekey).expires=expires next countkeyname="CartCount" Response.cookies(Cookiekey) (countkeyname)=cartcount Response.cookies(Cookiekey).expires=expires end sub ' Sub SessRestoreCart (field, value, cartcount, cookiekey, rc) dim arrcount, dataarea, Temparray(20), tempcount dim arrcart dim i, j, keyname, countkeyname dim cartattributes cartattributes=cMaxCartAttributes rc=0 ReDim arrcart(cartAttributes,getconfig("xmaxCartItems")) value=arrcart countkeyname="CartCount" cartcount=Request.cookies(Cookiekey) (countkeyname) If cartcount="" or Cartcount=0 then rc=4 exit sub end if ReDim arrcart(cartAttributes,getconfig("xmaxCartItems")) value=arrcart for i = 1 to cartcount keyname= field & cstr(i) dataarea=Request.cookies(Cookiekey) (keyname) ParseRecord dataarea, TempArray, tempcount, ";" for j = 1 to cartAttributes value(j,i)= temparray(j-1) next next end sub Sub Responseredirect(url) response.redirect url end sub %>