Domanda

I am working on a plugin that handles some more advanced searching of site members and in looking at the Advanced Search for the Site Members (cpublicusers.dsp_advancedsearch.cfm) I found that the way it does the pagination is that it sets the search form to the session. I tried to do the following using this code:

 <cfif NOT structKeyExists(SESSION,'reportForm')>

 <cfset SESSION.reportForm = FORM />

 <cfset sessionisset = true />

 <cfelse>
 <cfset sessionisset = false />

The sessionisset variable is just for my testing. When I try to navigate to the pagination I am finding that the session.reportForm variable is being cleared. Can anyone explain why this would be.

È stato utile?

Soluzione

FORM is a system structure that's re-initialized on each page. Structures are passed "by reference" meaning you're just storing a pointer to FORM. So when FORM is reinitialized - so is your session variable.

The fix is to make a deep copy of the structure so it's not affected by changes to FORM. view sourceprint?

<cfset SESSION.reportForm = duplicate(FORM) />
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top