Setting SessionTimeout in CF9 and CF10

I ran across a thread on the CFWheels Google Group where someone was having problems with setting a session timeout. I remembered that I had the same problem a few weeks back. I didn’t think anything of it after I found a solution though. Now, since I’m not the only one having this problem, I thought I’d blog it.

So the problem in a nutshell is that if you try to set a timeout to a number of seconds, it no longer works. My suspicion is that this behavior changed in ColdFusion 9, but was backwards compatible with using a number of seconds as the sessionTimeout value. Like this:
this.sessionTimeout = "3600"

When you read the CF9 documentation for cfapplication, you find this note as the description for sessionTimeout:

Life span of session variables. CreateTimeSpan function and values in days, hours, minutes, and seconds, separated by commas.

I am almost completely using CF10 now, and it appears that the old way of setting a number of seconds no longer works at all. Instead, the revised code for the sessionTimeout value should be:
this.sessiontimeout = CreateTimeSpan(0, 4, 0, 0);

When I dump the THIS scope in Application.cfc, I get the following output in a CFWheels Application:

Hope this helps someone.

NOTE: Code samples above use CFScript. Could be just as easily achieved using.

2 Replies to “Setting SessionTimeout in CF9 and CF10”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s