I am using a jquery UI based jquery idletimeout pl...
# cfml-beginners
m
I am using a jquery UI based jquery idletimeout plus and added all the necessary columns so when the Sessiontimeout is about to expire, it should extend it i have this code in my page
Copy code
<cffunction name="backupSession" returntype="struct">        
<cfset local.backup = StructNew()>
    <cflock scope="session" timeout="10">
        <cfset str = {}>
        <cfloop collection="#session#" item="i">
            <cfset str[i] = duplicate(session[i])>
        </cfloop>
        <cfset local.backup.Original = str>            
    </cflock>
    <cfreturn local.backup>
</cffunction>

<cffunction name="restoreSession" returntype="void" >
    <cfargument required="true" name="backup" type="struct">        
    <cflock scope="session" timeout="10">
        <cfset local.Liste=StructKeyList(arguments.backup)>    
        <cfloop index="i" from="1" to="#ListLen(local.Liste)#">    
            <cfset LeItem=ListGetAt(local.Liste,i)>
            <cfset session[LeItem]=arguments.backup[LeItem]>
        </cfloop>
    </cflock>
</cffunction>

<cfoutput>
    <cfset retData = backupSession()>
    #restoreSession(retData)#
</cfoutput>

my Application.cfm file has timeout set as 4 minutes to session, do i need to call my application also to extend the session, because even if i say stay connected, i gets logged out
m
Is there a reason you cannot set the timeout for your application's session to 10 minutes in the application.cfm (ignoring for a moment the fact that you should almost certainly refactor that to using a modern application.cfc based approach)?
m
i can but i am testing the functionality to see if the popup happens and i click stay connected, it should extend my session, but instead it just throws me out
m
I think maybe this article might help. Replace the "user interactions" Ben is talking about with your JQuery function that is firing asynchronously to re-up the session timeout. https://www.bennadel.com/blog/4283-ask-ben-extending-a-coldfusion-session-on-a-long-lived-page.htm
m
exactly using the same jquery timeout pls plugin, doing the same thing what Ben Explained here using a setTimeout Approach, it do calls the cfm page i have, but it just drops off after i click stay connected
m
Right, but Ben is using the application.cfc approach. application.cfm is called and executed on every single template load. In your case I think you are overwriting your "new" session timeout with every template load.
m
so you mean if Application.cfm is used and ajax calls a page extend.cfm and before executing extend, it calls application.cfm back again and logs it out
in that scenario, Can i add a piece of code that when extend is called, do not call Application.cfm
m
application.cfm is called by the engine. To not have it do that you must use application.cfc, which is the "modern" method of setting up your application variables. application.cfm is outdated and causes these kinds of problems all the time. It is also extremely inefficient. Definitely recommend a refactor, it will improve the performance of your app and give you more control.
m
@Mark Takata (Adobe) it seems the functions are not working properly, the restore and backup seems to be nesting the structure inside another structure whenever this page is called, it seems instead of overwriting the existing variables of session, it is creating a new set and put it inside an original struct, can you please check what is going mysteriously wrong here