--============_-1241802732==_ma============
Content-Type: text/plain; charset="us-ascii" ; format="flowed"
On 9/29/00, W Luke penned:
> > Use client variables, written to a database, whenever possible.
>
>Is there any documentation about writing client variables to a database? Or
>do you have any "starter for tens"?!
What kind of documentation? CF will create the necessary tables if
you just give it an empty database. The tables and columns it creates
are, in Access, I can't remember off the top of my head what the
matching data types are in SQL:
CDATA
cfid (text, 20 characters, no index)
app (text, 64 characters, indexed, duplicates OK)
data (memo)
CGLOBAL
cfid (text, 20 characters, indexed, duplicates OK)
data (memo)
lvisit (date/time, indexed, duplicates OK)
The biggest difference in the setup is, if you have complex objects
other than simple strings you have to serialize them into WDDX
packets. Then deserialize them into a local variable.
I do it like this:
To create the initial variable if it hasn't been created (my shopping
cart for example, this will probably wrap bad):
<cfif not isDefined("client.basket")>
<cfset variables.basket = queryNew("SearchRow, NewProduct_ID,
Product_ID, Product_Name, Quantity, Size, Style, Color, Order_Date,
Price_Per_Unit, Weight, Backordered, OptionTo")>
<CFWDDX INPUT="#variables.basket#" OUTPUT="MyBasket" ACTION="CFML2WDDX">
<cfset client.basket = MyBasket>
<cfelse>
<CFWDDX INPUT="#client.basket#" OUTPUT="variables.basket" ACTION="WDDX2CFML">
</cfif>
Then when adding something to the basket, whereas with sessions I
would just create a new basket called newbasket then set that to
session.basket, it's a tad more complex:
<!--- set the basket to the new values --->
<CFWDDX INPUT="#newbasket#" OUTPUT="MyBasket" ACTION="CFML2WDDX">
<cfset client.basket = MyBasket>
<CFWDDX INPUT="#client.basket#" OUTPUT="variables.basket" ACTION="WDDX2CFML">
But well worth it. Clustered server ready and NO CFLOCKS! YIPEEE!
Then I can just cfoutput or loop on variables.basket and access the
different items with variables.basket.product_id, etc. instead of
session.basket.etc
Oh, and if you want to give it a timeout, you can't just do it like
sessiontimeout=. You have to create a start time, then update it at
every click and delete the client variables if it's past the allotted
timeout (30 minutes in the example below). I do it like this:
<CFIF not isDefined('client.initialize_session')>
<cfset client.initialize_session = now()>
<cfelse>
<cfset app_timeout = now() - createtimespan(0,0,30,0)>
<CFIF client.initialize_session GTE app_timeout>
<cfset client.initialize_session = now()>
<CFELSE>
<cfset clientlist = GetClientVariablesList()>
<cfloop index="i" list="#clientlist#">
<cfset temp = DeleteClientVariable('#i#')>
</cfloop>
<cfset client.initialize_session = now()>
</CFIF>
</CFIF>
--
Bud Schneehagen - Tropical Web Creations
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
954.721.3452
--============_-1241802732==_ma============
Content-Type: text/html; charset="us-ascii"
<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { margin-top: 0 ; margin-bottom: 0 }
--></style><title>Re: Client & Session
variables?</title></head><body>
<div>On 9/29/00, W Luke penned:</div>
<blockquote type="cite" cite>> Use client variables, written to a
database, whenever possible.<br>
<br>
Is there any documentation about writing client variables to a
database? Or</blockquote>
<blockquote type="cite" cite>do you have any "starter for
tens"?!</blockquote>
<div><br></div>
<div>What kind of documentation? CF will create the necessary tables
if you just give it an empty database. The tables and columns it
creates are, in Access, I can't remember off the top of my head what
the matching data types are in SQL:</div>
<div><br></div>
<div>CDATA</div>
<div><x-tab> </x-tab>cfid
(text, 20 characters, no index)</div>
<div><x-tab> </x-tab>app
(text, 64 characters, indexed, duplicates OK)</div>
<div><x-tab> </x-tab>data
(memo)</div>
<div>CGLOBAL</div>
<div><x-tab> </x-tab>cfid
(text, 20 characters, indexed, duplicates OK)</div>
<div><x-tab> </x-tab>data
(memo)</div>
<div><x-tab> </x-tab>lvisit
(date/time, indexed, duplicates OK)</div>
<div><br></div>
<div>The biggest difference in the setup is, if you have complex
objects other than simple strings you have to serialize them into
WDDX packets. Then deserialize them into a local variable.</div>
<div><br></div>
<div>I do it like this:</div>
<div><br></div>
<div>To create the initial variable if it hasn't been created (my
shopping cart for example, this will probably wrap bad):</div>
<div><br></div>
<div><font size="-2"><cfif not
isDefined("client.basket")><br>
<cfset variables.basket = queryNew("SearchRow, NewProduct_ID,
Product_ID, Product_Name, Quantity, Size, Style, Color, Order_Date,
Price_Per_Unit, Weight, Backordered, OptionTo")><br>
<CFWDDX INPUT="#variables.basket#"
OUTPUT="MyBasket" ACTION="CFML2WDDX"><br>
<cfset client.basket = MyBasket><br>
<cfelse><br>
<CFWDDX INPUT="#client.basket#"
OUTPUT="variables.basket"
ACTION="WDDX2CFML"></font></div>
<div><font size="-2"></cfif></font></div>
<div><br></div>
<div>Then when adding something to the basket, whereas with sessions
I would just create a new basket called newbasket then set that to
session.basket, it's a tad more complex:</div>
<div><br></div>
<div><!--- set the basket to the new values ---></div>
<div><font size="-1"><CFWDDX INPUT="#newbasket#"
OUTPUT="MyBasket" ACTION="CFML2WDDX"><br>
<cfset client.basket = MyBasket></font></div>
<div><font size="-1"><CFWDDX INPUT="#client.basket#"
OUTPUT="variables.basket"
ACTION="WDDX2CFML"></font></div>
<div><font size="-1"><br></font></div>
<div>But well worth it. Clustered server ready and NO CFLOCKS!
YIPEEE!</div>
<div><br></div>
<div>Then I can just cfoutput or loop on variables.basket and access
the different items with variables.basket.product_id, etc. instead of
session.basket.etc</div>
<div><br></div>
<div>Oh, and if you want to give it a timeout, you can't just do it
like sessiontimeout=. You have to create a start time, then update it
at every click and delete the client variables if it's past the
allotted timeout (30 minutes in the example below). I do it like
this:</div>
<div><br></div>
<div><font size="-1"><CFIF not
isDefined('client.initialize_session')><br>
<cfset client.initialize_session = now()><br>
<cfelse></font></div>
<div><font size="-1"><cfset app_timeout = now() -
createtimespan(0,0,30,0)></font></div>
<div><font size="-1"> <CFIF
client.initialize_session GTE app_timeout><br>
<cfset client.initialize_session = now()><br>
<CFELSE><br>
<cfset clientlist =
GetClientVariablesList()><br>
<cfloop
index="i" list="#clientlist#"><br>
<x-tab> </x-tab> <cfset temp =
DeleteClientVariable('#i#')><br>
</cfloop><br>
<cfset
client.initialize_session = now()><br>
</CFIF></font></div>
<div><font size="-1"></CFIF></font></div>
<div>-- <br>
<br>
Bud Schneehagen - Tropical Web Creations<br>
<br>
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/<br>
ColdFusion Solutions / eCommerce Development<br>
[EMAIL PROTECTED]<br>
http://www.twcreations.com/<br>
954.721.3452</div>
</body>
</html>
--============_-1241802732==_ma============--
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.