views:

337

answers:

3

Here's my Application.cfc code:

< cfcomponent> < cfset this.applicationname="cfGossip"> < cfset this.applicationname="true"> < cfset this.sessionManagement = true /> < /cfcomponent>

My session is called "Session.MM_Username" I want to 'kill' it when a browser is closed. How do I do this? Can somebody try construct the code for my Application page to do this? Thanks.

A: 

Basically, you need to create a "session cookie" - that is, a cookie with no expiry date. It will be removed when the browser window is closed.

I don't know how to do this off hand with CF, but this will probably help: http://www.google.com/search?q=cold+fusion+session+timeout

Possibly by setting:

this.sessiontimeout = ""
David Wolever
David's concept is correct, although in Coldfusion it's best implemented using Henry's solution: J2EE servlet session management, which will automatically create and handle session cookies for you.
Dan Sorensen
A: 

Your CFID and CFTOKEN cookies need to be set at session cookies like this:

<cfapplication     
     sessionmanagement="Yes"
     name="MyApplication"
     setclientcookies="No"
     sessiontimeout=#CreateTimeSpan(0, 0, 1440, 0)#>

<cfcookie name="CFID" value="#SESSION.CFID#" />
<cfcookie name="CFTOKEN" value="#SESSION.CFTOKEN#" />
ryber
If you use Application.cfc, do it in onSessionStart()
Henry