Skip to main content
Known Participant
September 3, 2020
Question

Multiple session timeouts for remote functions

  • September 3, 2020
  • 3 replies
  • 721 views

Coldfusion Session Timeout:

Been reading through numerous posts regarding this.sessiontimeout and how to adjust it depending on who/what is running. For instance, My users log in, and I want their sessions to end in 10 hours (I know, but I have people who don't do anything for hours and don't want to have to log back in). I have a program that runs, and I need those sessions to end in 5 seconds of inactivtity (or I end up with hundreds of sessions showing up on fusionreactor).

 

Reading through the various articles, I'm getting mixed messages.

So, my question....
If I invoke a remote CFC from another server, it creates a session. If I put at the top of the Application.cfc

<cfif findnocase(ListLast(CGI.SCRIPT_NAME, "/"), "Viewall") gt 0>
     <cfset this.sessiontimeout = CreateTimeSpan(0,0,0,5)>
</cfif>

 

 

Did I just set the sessiontimeout for EVERYONE or just for that "Viewall" call?

REALLY, thank you for your time.

This topic has been closed for replies.

3 replies

Participating Frequently
September 8, 2020

If you create a sub directory with the CFC containing the remote functions and also have a separate Application.cfc, with the shorter session requirements in the same sub directory, any calls to the remote functions will use the new Application.cfc and not affect the main application. The Application.cfc in the  sub directory will need to specify a different application id.

BKBK
Community Expert
Community Expert
September 6, 2020

 

 

 

<!--- 
Sets the session time-out to 5 seconds for EVERY user 
of the application 
--->
<cfset this.sessiontimeout = CreateTimeSpan(0,0,0,5)>

<!--- 
Sets or changes the session time-out to 5 seconds for EVERY user of 
the application, once some user requests a page containing "Viewall"
--->
<cfif findnocase(ListLast(CGI.SCRIPT_NAME, "/"), "Viewall") gt 0>
     <cfset this.sessiontimeout = CreateTimeSpan(0,0,0,5)>
</cfif>

 

 

WolfShade
Legend
September 3, 2020

Hello, Ed,

 

According to Adobe Help, the "this" scope is for the user session.

 

Life span, as a real number of days, of the user session, including all Session variables. Use the CFML CreateTimeSpan function to generate this variable's value.

 

So, if the remote call creates a new session, then you should be limiting the session for just that remote call.  This is not gospel, this is my best guess.

 

V/r,

 

^ _ ^

 

UPDATE.. I may have read your question wrong.  The current user session is making a remote call, not the other way around.  So, yes, you'd be setting a timeout for that user's session.

Participant
September 6, 2020

I thank you for your insight. I implemented the change and it appears to be working as I had hoped it would - timing out just the one session. 

BKBK
Community Expert
Community Expert
September 7, 2020

Please note: this.sessionTimeout is an application setting, not a session setting or user setting.