tags:

views:

73

answers:

2

If I'm building a high-traffic site, and I don't want to use session for the front pages. Is it possible to enable session only for pages in certain subfolders, while sharing the same Application scope?

Thanks!

+1  A: 

I don't believe so. My understanding is that session settings are per-application. However, if you are simply using the application scope to store configuration variables (or similar) then you could create two application.cfm/application.cfc files that include a shared file with the config data.

Ben Doom
I want to share the same ColdBox instance.. :)
Henry
+1  A: 

It's possible, but be careful, as you could have things leak out that you don't want to. Take the following file structure:

wwwroot
-- Application.cfc
-- index.cfm
-- Subfolder
---- Application.cfc
---- index.cfm

Application.cfc:

<cfcomponent>
    <cfset this.name = "foobar" />
    <cfset this.applicationtimeout = CreateTimeSpan(1,0,0,0) />
    <cfset this.sessionmanagement = false />

    <cffunction name="onApplicationStart">
     <cfset Application.Started = Now() />
    </cffunction>

</cfcomponent>

index.cfm:

<cfdump var="#Application#">
<cfdump var="#Session#" />

Subfolder/Application.cfc

<cfcomponent extends="Application">
    <cfset this.sessionmanagement = true />

</cfcomponent>

Subfolder/index.cfm

<cfdump var="#Application#">
<cfdump var="#Session#">

A dump in the root index.cfm will show no values for cfid, sessionid, cftoken, etc. However, a dump in Subfolder/index.cfm will show all of the usual session information. Both index.cfm files will dump the same started value in the Application scope.

Dan

Daniel Short
Last time I tried, extends="Application" doesn't work.
Henry
Of course... you need to use an ApplicationProxy. I was using some live code that used extends="scribble.Application" and I just removed the scribble directory. More on ApplicationProxy at http://www.dansshorts.com/post/extending-the-root-application-cfcSorry about that...Dan
Daniel Short
thanks! awesome.
Henry
You're welcome :). I use this all the time for enabling sessions in specific directories for stuff like flash-based uploaders that do asynchronous calls to directories that are outside of our standard Session tracked applications.
Daniel Short
you don't need to use an applicationproxy. to extend the application.cfc in root directory from an application.cfc in a subfolder, you just have to do extend="./application">
rip747