Search code examples
sessioncoldfusionstruts

Deleting a session/structure with coldfusion


I have a session which is a collection of structures

SESSION.squad.achievements[key]

so it may be

SESSION.squad.achievements[2010] = "swam the english channel";
SESSION.squad.achievements[2009] = "ran a marathon";
SESSION.squad.achievements[2008] = "cycled Le Tour";

My code deletes the stucture temporarily, but does not delete the session so when I refresh the value still exists

<cfset myYear = #myYear# />
<cfset #StructDelete(SESSION.squad.achievements, myYear)#>

Any ideas how I can delete this value?


Solution

  • Try using cflock

    <cflock timeout="30" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
        <cfset StructDelete(SESSION.squad.achievements, myYear)>
    </cflock>