I just thought of a way of doing this in one step, and it will work 
globally for all fusebox applications!

You use the CF_LOCATION tag, instead of CFLOCATION, and set the online 
cookie in one step.  AND it should work with WHATEVER your default 
FuseAction is in your index.cfm. AND it does not matter if you have 
security turned on, or not, or whatever.  It will always destroy their 
client (or session vars, if you want) whenever they close their browser.

Put this code in a global location, say app_global.cfm.

===============================
<CFIF Not IsDefined("Cookie.Online")>

          <CFLOOP  LIST="#GetClientVariablesList ()#" index="curvar">
                  <CFSET temp=DeleteClientVariable(curvar) >
          </cfloop>

         <CFCOOKIE name="ONLINE" value="TRUE">

          <CF_LOCATION url="index.cfm?fuseaction=main">

         <!--- OR IF YOU WANT YOUR DEFAULT FUSEACTION, TRY THIS --->
          <CF_LOCATION url="index.cfm">

</CFIF>
===============================


BTW, this code has the added side effect of forcing the user to come to the 
main fuseaction (or whichever one you set) when they first come to the 
site.  ie, you can't open a link to any other fuseaction as the first page, 
and expect it to work.  This may or may not be desired.

I guess you could fix that like this, but you will need to run the code 
after the <CF_URLFORM2ATTRIBUTES> tag:

<CF_LOCATION url="index.cfm?fuseaction=#attributes.fuseaction#">


At 11:54 AM 5/8/01, Douglas Smith wrote:

>At 03:43 AM 5/8/01, Akhmad Makki wrote:
>
> >how can i dispose client variables automatically
> >when the user closes his browser ? please help.
> >
> >thanks, Makki
>
>Here is how you do it:
>
>1) Give the user a temporary cookie in the logon page.  Don't use the
>EXPIRES option, which creates a cookie that is destroyed when they close
>their browser.  You can also set this cookie after they logon, but your
>must use the <CF_LOCATION> tag instead of <CFLOCATION> if you set the
>cookie in an action page.
>
>Let's call it cookie.online.
>
><CFCOOKIE name="ONLINE" value="TRUE">
>
>2) In your application.cfm or your security fuse, check if the user has
>this cookie.  If they don't, it means they closed their browser, and must
>logon again.  But, before you send them to the logon screen, destroy all
>their client variables.  You must not run this code for the logon or logon
>action page, otherwise you get an infinite loop.
>
><CFIF Not IsDefined("Cookie.Online")>
>
>          <CFLOOP  LIST="#GetClientVariablesList ()#" index="curvar">
>                  <CFSET temp=DeleteClientVariable(curvar) >
>          </cfloop
>
>          <CFLOCATION url="index.cfm?fuseaction=logon">
>
></CFIF>
>
>
>
>================================================
>Douglas M. Smith - Application Architect
>TeraTech - Tools for Programmers(tm)
>[EMAIL PROTECTED]
>================================================
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to