Get a Quote Today!   |   + 1 (301) 424 3903




 
  Community
 
Need Help?
Visit our Training page
Request a Quote or Consultation
SIGN UP FOR THE TERATECH NEWSLETTER
 

ColdCuts

Cut: Another way to kill the Client/Session when the browser closes
Cut#: 285 
Cut Date: 04/23/2002 
Cutter: Douglas Smith 
Topic: Session Management 
Overview: Often, people set the cfid/cftoken cookes so they will expire when the browser closes. This code is more elegant, since it does not mess with the cfid/cftoken cookies set by CF server. Note that the session is not killed until the next time the user comes to the web site, but this does not changes the way the web site behaves from the user's perspective.

This code would go in your application.cfm, or other global location.

This method requires the CF_LOCATION custom tag.

 

Cut Code:

<!--- CODE TO DESTROY SESSION/CLIENT ON BROWSER CLOSE --->
<CFIF Not IsDefined("Cookie.Online")>
<!--- DESTROY CLIENT VARS --->
<CFLOOP LIST="#GetClientVariablesList()#" index="curvar">
<CFSET temp=DeleteClientVariable(curvar) >
</cfloop>
<!--- SET THE ONLINE COOKIE --->
<CFCOOKIE name="ONLINE" value="TRUE">
<CF_LOCATION url="#Request.URLRoot#index.cfm?fuseaction=main" AddToken=True DoSlash=False>
</cfif>