session.setMaxInactiveInterval() in Lucee?

My app sets the session timeout to 30 minutes. In a couple of programs, I need to extend this to 4 hours in order to wait for a COM call that may take more than 30 minutes to complete.

In ACF I used the undocumented session.setMaxInactiveInterval(), but this does not appear to work in Lucee.

Is there a way to accomplish this in Lucee and avoid the session terminating before the COM call completes?

Thanks.

We have the same problem. Did you find a solution by a chance? Thanks.

No, unfortunately. For Lucee installs, I have to raise the session timeout. It’s a waste of resources, but I couldn’t find any alternative.

It is indeed a big waste of resources. Search bots make a lot of visits to our servers, and in ACF, we can reduce their session TTL to 3 minutes, but allow logged in users to have much longer sessions.

If you can identify the session you want to terminate early, then the following might be helpful:

Ben Nadel, Explicitly Ending A ColdFusion Session

There seems to be a method with that name available via the page context. Perhaps worth trying to see if it does what you want:

GetPageContext().getSession().setMaxInactiveInterval( 14400 );

Otherwise as the post Bill referred to says, you can vary session timeouts per request based on a flag/identifier of some kind.

Julian, thanks I’ll give it a try.

We also rely heavily on setMaxInactiveInterval() in ACF to set sessions that are created by bots down to a couple of minutes, and actual user sessions much longer.

I’ve been struggling with this too, Lucee 5.2.9.31.

In my case I would like to grant some users a whole day session but all the rest quite a short timeout.

No matter what I’ve tried, I don’t seem to be able to change it from

this.sessionTimeout = CreateTimeSpan(0, 1, 0, 0);

which is my default at the moment.

I tried

GetPageContext().getSession().setMaxInactiveInterval( 14400 );

but this doesn’t seem to change anything in getApplicationMetadata() - but perhaps I’m looking in the wrong place?

I accept that Ben Nadel’s solution probably works, but I don’t want to have to have a special url variable on every page for the long-session users. With the idea that it might be possible to actually have swapable timeouts stored as a session variable which could be altered once the user had logged in, I tried this, the new session.customTimeout value is written to session, but nothing seems to be changing in getApplicationMetadata()

this.sessionManagement = true;
cfparam(name="session.customTimeout" default = CreateTimeSpan(0, 1, 0, 0));
this.sessionTimeout = session.customTimeout;

Any other ideas?

Thanks

Richard

Richard:

I’m not sure about getApplicationMetadata() results relative to this function.

I used GetPageContext().getSession().getMaxInactiveInterval() to validate the setting. I’m fairly certain that I validated the session lasting longer than the time set in the application.cfc, but I don’t exactly remember how I did that.

I also use the following code to “shutdown” scheduled tasks:

<cftry>
	<cfset PageContext = GetPageContext() />
	<cfset PageContext.getSession().setMaxInactiveInterval(1) />
	<cfcatch type="any">
		<cfset session.setMaxInactiveInterval(1) />
	</cfcatch>
</cftry>
<cfset StructDelete(cookie, "CFID") />
<cfset StructDelete(cookie, "CFToken") />

Bill

There’s a BIF for that