• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Session varaibles available after page refresh

Explorer ,
Dec 09, 2015 Dec 09, 2015

Copy link to clipboard

Copied

Hi,

When I add another session variable in the application.cfc file and access it in the login page, it does not appear in other pages.

Current session variables change after I select the refresh button on the IE browser.

Using Cold Fusion 11 and IE browser version 9.

The Enable Session Variables option in the Cold Fusion admin is enabled.

Is there any solution to have the session variables available without having to refresh the page and have the new session variables available?

Thanks,

Mike

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 09, 2015 Dec 09, 2015

Copy link to clipboard

Copied

Can you show us your application.cfc file? And any relevant .cfm files where a session variable "disappears" or is otherwise unavailable?

-Carl V.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 10, 2015 Dec 10, 2015

Copy link to clipboard

Copied

Hi,

In the application.cfc, Session.ULTC1002.TASummary, Session.Ultc1002.TADelete and Session.Ultc1002.TADeleteN are declared.

The session variables, Session.Ultc1002.TADelete and Session.Ultc1002.TADeleteN are not changing.
These variables are set the application.cfc and the login page.
The value of the variables are changed in the display page. It seems when new session
variables are added, they do not function properly.

The variables (Session.Ultc1002.TADelete and Session.Ultc1002.TADeleteN) are used in the Navigation cfm. But do not change. The variables are changed in the display page.
The Session.ULTC1002.TASummary variable will change after the refresh button is selected.

Mike


------ application.cfc ------

<!--- Application Page for the Ultc100.2 program --->


<cfcomponent output="false">

<!--- Application name, should be unique --->
<cfset this.name = "ULTC1002">
<!--- Application name, should be unique --->
<cfset this.datasource = "dd">
<cfset this.datasourcereport = "hh">
<CFSET CURRENTDATE=#DATEFORMAT(Now(), "MM/DD/YYYY")#>
<CFSET CURRENTTIME=#TIMEFORMAT(NOW(),"h:mm:ss tt")#>
<!--- How long application vars persist --->
<cfset this.applicationTimeout = createTimeSpan(0,0,30,0)>
<!--- Should client vars be enabled? --->
<cfset this.clientManagement = false>
<!--- Should we even use sessions? --->
<cfset this.sessionManagement = true>
<!--- Where should cflogin stuff persist --->
<cfset this.loginStorage = "Session">

<!--- How long do session vars persist? --->
<cfset THIS.sessionTimeout = createTimeSpan(0,0,30,0)>
<!--- Should we set cookies on the browser? --->
<cfset THIS.setClientCookies = false />
<!--- should cookies be domain specific, ie, *.foo.com or www.foo.com --->
<cfset THIS.setDomainCookies = false />
<!--- should we try to block 'bad' input from users --->
<cfset THIS.scriptProtect = true />
<!--- should we secure our JSON calls? --->
<cfset THIS.secureJSON = false />
<!--- Should we use a prefix in front of JSON strings? --->
<cfset THIS.secureJSONPrefix = "" />

<!--- define custom coldfusion mappings. Keys are mapping names, values are
full paths --->
<cfset this.mappings = structNew()>

<!--- Run when application starts up --->
<cffunction name="onApplicationStart" returnType="boolean" output="false">
<cfreturn true>
</cffunction>


<!--- Runs when your session starts --->
<cffunction name="onSessionStart" returnType="void" output="false">
<cfif #StructKeyExists(Session, "ULTC1002")#>      
<cflock scope="session" type="Readonly" timeout="30"> 
<cfset Session.ULTC1002 = structNew()>
<cfset Session.Ultc1002.ErrorMsg = "">
<cfset Session.ULTC1002.LoggedIn = " ">
<cfif Session.ULTC1002.LoggedIn eq "T">
<cfset Session.Ultc1002.LoggedUser = "">
<CFSET Session.Ultc1002.AdminUser = "">
<CFSET Session.Ultc1002.UserName = "">
<CFSET Session.Ultc1002.FacilityNum = "">
<CFSET Session.Ultc1002.Class = "">
<CFSET Session.Ultc1002.UserID = "">
<CFSET Session.Ultc1002.UserName = "">
<CFSET Session.Ultc1002.ClientCall = "">
<CFSET Session.Ultc1002.ClientLname = "">
<CFSET Session.Ultc1002.ClientDOB = "">
<CFSET Session.Ultc1002.ClientStateID = "">
<CFSET Session.ULTC1002.ssnvar = "">
<CFSET Session.ULTC1002.LimitToOrganization = "">
<CFSET Session.Ultc1002.AdminUser = "">
<CFSET Session.Ultc1002.ltc803date = "">
<CFSET Session.ULTC1002.LTC803Call = "">
<CFSET Session.Ultc1002.AssessmentError = "">
<CFSET Session.Ultc1002.LognoteCall = "">
<CFSET Session.Ultc1002.CertCall = "">
<CFSET Session.Ultc1002.PasarrCall = "">
<CFSET Session.Ultc1002.Deleted = "">
<CFSET Session.Ultc1002.Copied = "">
<CFSET Session.Ultc1002.Finished = "">
<CFSET Session.ULTC1002.StatusCall = "">
<CFSET Session.ULTC1002.ProgramCall = "">
<CFSET Session.ULTC1002.Event = "">
<CFSET Session.ULTC1002.AssessCall = "">
<CFSET Session.ULTC1002.AssessLognoteAdd = "">
<CFSET Session.ULTC1002.ErrorMsg = "">
<CFSET Session.ULTC1002.ErrorCount = "">
<CFSET Session.ULTC1002.LognotesCall = "">
<CFSET Session.ULTC1002.OldEvent = "">
<CFSET Session.Ultc1002.PrintCall = "">
<CFSET Session.Ultc1002.AppealCall = "">
<CFSET Session.Ultc1002.LognotePrint = "">
<CFSET Session.Ultc1002.AssessmentPrint = "">
<CFSET Session.Ultc1002.LookupCalledMe = "">
<CFSET Session.ULTC1002.CIRSEntryID = "">
<CFSET session.ULTC1002.ReferralDate = "">
<CFSET session.ULTC1002.ReferralCall = "">
<CFSET Session.ULTC1002.SPDDPlanEvent = "">
<CFSET Session.ULTC1002.DDSPlanServiceCall = "">
<CFSET Session.Ultc1002.Complaint = "">
<CFSET Session.ULTC1002.ComplaintServiceCall = "">
<CFSET Session.ULTC1002.ComplaintID = "">
<CFSET Session.ULTC1002.CIRSServiceCall = "">
<CFSET Session.ULTC1002.SPCopied = "">
<CFSET Session.ULTC1002.TAEvent = "">
<CFSET Session.ULTC1002.TAServiceCall = "">
<CFSET Session.ULTC1002.TASummary = "">
<CFSET Session.ULTC1002.RiskPlanEvent = "">
<CFSET Session.ULTC1002.RiskPlanCall = "">
<CFSET Session.ULTC1002.RiskID = "">
<CFSET Session.Ultc1002.View = "">
<CFSET Session.Ultc1002.TADelete = "">
<CFSET Session.Ultc1002.TADeleteN = "">


<cfelse>
<cfif NOT StructKeyExists(session, "UTLC1002") OR NOT Session.ULTC1002.LoggedIn>
<cfif Session.ULTC1002.LoggedIn EQ "F" OR Session.ULTC1002.LoggedIn EQ "">
<cfset Session.Ultc1002.ErrorMsg = "">
</cfif>

</cfif>
</cfif>
</cflock>
</cfif>
<CFSET Session.dog = "">
<cfoutput>
<cfif #HTTPS# EQ "Off"><cflocation url="https://#SERVER_NAME##PATH_INFO#" addtoken="no"></cfif>
</cfoutput>


<cfreturn />

</cffunction>


<!--- Run before the request is processed --->
<cffunction name="OnRequestStart" access="public" returntype="boolean" output="true"
hint="Fires at first part of page processing.">
<LINK href="pppp" type="text/css" rel="stylesheet">
<cfreturn true />
</cffunction>

<cffunction name="onMissingTemplate">
<cfargument name="targetPage" type="string" required=true/>
<!--- Use a try block to catch errors. --->
<cftry>
<!--- Log all errors. --->
<cflog type="error" text="Missing template: #Arguments.targetPage#">
<!--- Display an error message. --->
<cfoutput>
<h3>#Arguments.targetPage# could not be found.</h3>
<p>You requested a non-existent page.<br />
Please check the URL.</p>
</cfoutput>
<cfreturn true />
<!--- If an error occurs, return false and the default error
handler will run. --->
<cfcatch>
<cfreturn false />
</cfcatch>
</cftry>
</cffunction>


<!--- Runs before request as well, after onRequestStart --->

<cffunction name="onRequest" returnType="void">
<cfargument name="thePage" type="string" required="true">
<cfinclude template="#arguments.thePage#">

       <!---Setting the give_me_more_time session variable refreshes the session.--->

       <script language="javascript">
            var minutes=30
         var seconds=60
         document.title='Benefits Utilization System - Session timeout in approximately ' + minutes + ' minutes'
               
         function display()
         {        
          seconds-=1
         
          if (seconds<=0)
          {
           seconds=60
           minutes-=1
           document.title='Benefits Utilization System - Session timeout in approximately ' + minutes + ' minutes'
           if (minutes<=0)
           {
            alert("As a security measure your session has timed out, you will be redirected to the login screen and any unsaved data will be lost.  We apologize for any inconvenience that this may cause.")
            window.location.replace("https://sp0.hcpf.state.co.us/Mercury/MainMenu.aspx")
           }
          }
             setTimeout("display()",1000) 
         }
        
         display()
        
       </script>         
  

</cffunction>
<!--- Runs at end of request --->
<cffunction name="onRequestEnd" returnType="void" output="false">
<cfargument name="thePage" type="string" required="true">

</cffunction>
<!--- Run when application stops --->
<cffunction name="onApplicationEnd" returnType="void" output="false">
<cfargument name="applicationScope" required="true">
</cffunction>


<!--- Runs when session ends --->
<cffunction name="onSessionEnd" returnType="void" output="false">
<cfargument name="sessionScope" type="struct" required="true">
<cfargument name="appScope" type="struct" required="false">

</cffunction>
</cfcomponent>


----- Navigation cfm ------


<cfoutput>


<CFIF #Session.Ultc1002.Class# eq "TCA">

</cfif>
del #Session.Ultc1002.TADelete#  cla #Session.Ultc1002.Class#  sum #Session.ULTC1002.TASummary#
<cfif Session.Ultc1002.TCATRAN eq "Y">
<Cfset #Session.ULTC1002.TAServiceCall# = "View">
</cfif>

<cfif #Session.Ultc1002.TADelete# eq "YES">


<CFelseIF (#isdefined("taassessmentsummary")# and #isdefined("form.Summarydeleted")# and #isdefined("form.Summaryfinalized")# )>
<P align="center"><INPUT TYPE="Submit" NAME="btnSPInsert" VALUE=" Save "> 
<CFelseIF #isdefined("taassessmentsummary")# eq "Yes" and #isdefined("form.Summarydeleted")# eq "Yes" >

<CFelseIF #isdefined("taassessmentsummary")# eq "Yes" and #isdefined("form.Summaryfinalized")# eq "Yes" >  
   
<CFelseIF isdefined("talastscreen") >
<P align="center"><INPUT TYPE="Submit" NAME="btnSPInsert" VALUE=" Save "> 
<CFelseIF #Session.ULTC1002.TAServiceCall# eq "View" or #isdefined("form.Interm")#
or #isdefined("form.Final")# or #isdefined("form.Blank")#>

<cfelse>       
<P align="center"><INPUT TYPE="Submit" NAME="btnSPInsert" VALUE=" Save "> 
<INPUT TYPE="Submit" NAME="btnSaveAndcontinue" VALUE="Save and Continue"> 
</cfif>

</cfoutput>
<cfinclude template="sharedbottom.cfm">


------ Part of the login page ------

    <cfif #Class_Var# eq 'xx'>
  <CFLOCATION URL="lognote/fileupload.cfm" addtoken="no">
  <cfelseif #Session.Ultc1002.Class# neq "xx">
  <cfif (#Session.Ultc1002.Class# EQ "yy")>
   <CFSET Session.Ultc1002.View = "N">
                        <CFSET Session.Ultc1002.TCATRAN = "N">
                        <CFSET Session.Ultc1002.TCAView = "N">
   <CFSET Session.Ultc1002.TADelete = "">
   <CFSET Session.Ultc1002.TADeleteN = "">
  <cfelseif (#Session.Ultc1002.Class# EQ "TCA")>
                        <CFSET Session.Ultc1002.View = "N">
   <CFSET Session.Ultc1002.TCATRAN = "N">
                        <CFSET Session.Ultc1002.TCAView = "Y">
   <CFSET Session.Ultc1002.TADelete = "">
   <CFSET Session.Ultc1002.TADeleteN = "">   
  <CFelse>
   <CFSET Session.Ultc1002.View = "N">
                        <CFSET Session.Ultc1002.TCATRAN = "Y">
                        <CFSET Session.Ultc1002.TCAView = "N">
   <CFSET Session.Ultc1002.TADelete = "">
   <CFSET Session.Ultc1002.TADeleteN = "">
  </CFIF>
<CFLOCATION URL="mainmenu.cfm?Session.Ultc1002.View=#Session.Ultc1002.View#" addtoken="no">
    </cfif>


------ Part of the display page ------

  <cfif #Session.Ultc1002.TCATRAN# eq "N">
<CFIF #Session.Ultc1002.ClientCall# neq "View" and #tatransitiondates.Finalized# eq "0"  > 
          <CFFORM NAME="AssessmentGrid" ACTION="taassessmentdates.cfm?Session.Ultc1002.TADelete=NO&Session.ULTC1002.TASummary=NO" METHOD="Post">  
                <INPUT TYPE="Submit" NAME="Edit" VALUE="Edit">
                <CFSET View_val = "NO">
                <INPUT TYPE="Hidden" NAME="EventNum" VALUE="#tatransitiondatesretrieve.Event_number#">
  <INPUT TYPE="Hidden" VALUE='<CFIF #Session.Ultc1002.ClientCall# neq "View" and #tatransitiondates.Finalized# eq "">Edit<cfelse>View</cfif>' NAME="CalledMe">
   </cfform>
         <CFELSE>
    <CFFORM NAME="AssessmentGrid" ACTION="taassessmentdates.cfm?Session.Ultc1002.TADelete=NO&Session.ULTC1002.TASummary=YES" METHOD="Post">
             <INPUT TYPE="Submit" NAME="View" VALUE="dddView">
             <CFSET View_val = "YES">
             <INPUT TYPE="Hidden" NAME="EventNum" VALUE="#tatransitiondatesretrieve.Event_number#">
      <INPUT TYPE="Hidden" VALUE='<CFIF #Session.Ultc1002.ClientCall# neq "View" and #tatransitiondates.Finalized# eq "">Edit<cfelse>View</cfif>' NAME="CalledMe">
      <Cfset Session.ULTC1002.TAServiceCall = "View">
    </cfform>
          </CFIF>
   <CFelse>
        <Cfset Session.ULTC1002.TAServiceCall = "View">
        <INPUT TYPE="Submit" NAME="View" VALUE="View">
   </cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 10, 2015 Dec 10, 2015

Copy link to clipboard

Copied

LATEST

I'm not sure if this is the problem or not, but take a look at your ACTION attributes on your CFFORM tags.  You are putting references to session variables in URL parameters, which will become URL scope variables on the receiving page (so Session.Ultc1002.TADelete will end up as URL.Session.Tltc1002.TADelete on taassessmentdates.cfm, and the same for the other variables you set).  That may not be what you intended.  Also, since you are using the POST method, you might as well store those values in hidden input fields so they become part of the form post payload.  You should also simplify the input name to just TADelete.  On taassessmentdates.cfm, you should then grab the value from FORM.TADelete and put it into Session.TLtc1002.TADelete (if that is what you intended).

A couple editorial notes:

  • Ouch - that's a lot of CFSETs to generate a single structure within the session scope.  That looks like a good candidate for refactoring with <cfscript>. 
  • There is absolutely no reason to be using <CFFORM> in your display page - just use plain old <FORM> (especially since you aren't using <CFINPUT> anyway).

HTH,

-Carl V.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation