Copy link to clipboard
Copied
HI,
I'm running CF 9.
Because I have sub domains, I have to write the session cookes manually in my application.cfm, otherwise we lose session variables as we cross sub domains. (does not happen in Firefox but does happen in IE, Chrome, Safari)
But these manual written session cookies cause other problems so I really need to let CF write the session cookies.
The problem is that I need the domain to have the dot in front of it, and CF default is to not use the dot:
i.e. in my manual cookies I set the domain to ".mydomain.com"
But if I let CF write the session cookies, it defaults to "mydomain.com" with out the dot
Is there a way to tell CF to use the dot vesion when it writes cookies?
I do have multiple sites on this server, so if I change something in JRUN, it has to be domain specific and can't apply to all the domains on this web site.
So I am looking for something I can add in a application.cfm or application.cfc
Here is what my manual session cookies look like:
<cfcookie name="CFID" value="#Session.CFID#" expires="never" domain=".mydomain.com">
<cfcookie name="CFToken" value="#Session.CFToken#" expires="never" domain=".mydomain.com">
Copy link to clipboard
Copied
In my opinion, you have been doing it the right way. My advice is that you should persevere. All you have to do is figure out how solve the "other problems" you encountered.
For example, use Application.cfc in preference to Application.cfm. Enable session management and, since you are writing session cookies manually, set setClientCookies to false. Here is an idea to get you started
<cfcomponent displayname="Application file">
<cfscript>
this.name = "my_app";
this.applicationTimeout = "#createTimespan(1,0,0,0)#";
this.sessionManagement = "true";
this.sessionTimeout = "#createTimeSpan(0,0,20,0)#";
this.setClientCookies = "false";
</cfscript>
<cffunction name="onSessionStart">
<cfif NOT isDefined( "cookie.cfid" ) OR NOT isDefined( "cookie.cftoken" )>
<cfcookie name="CFID" value="#Session.CFID#" expires="never" domain=".mydomain.com">
<cfcookie name="CFToken" value="#Session.CFToken#" expires="never" domain=".mydomain.com">
</cfif>
</cffunction>
<cfcomponent>