Deleting Session Variables with Checkbox - 500 points

We are currently using client variables to set the search criteria for our search pages and we would like to move them over to session variables due to the database load they are putting on our SQL server.  I have been successful moving over some of the variables to session variables, but I am getting stuck on session variables that are being set through the use of a check box on a form.  

Once I check the checkbox, the session variable intdata is set, but when I try to uncheck the intdata checkbox, the box stays checked.  This is the same code that is used for the client variables and they check and uncheck correctly.  What am I missing????

Below is some of the code that sets the variable and the code of the form with the checkboxes.  I have been trying to use the StructDelete for the intdata variable, but it doesn't seem to be deleting the session variable.  

Setting and Deleting the Variable

<!--- Int Data --->
<CFIF isdefined("form.intdata")>
<cflock timeout="30" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
      <CFSET session.intdata = 1>
</cflock>
</cfif>

<CFIF isdefined("url.keepInt") and isdefined("session.intdata")>
      <CFELSEIF not isdefined("form.intdata") and isdefined("session.intdata")>
            <cflock timeout="30" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
                  <CFSET StructDelete (session, "intdata")>
            </cflock>
</cfif>


Code of the form with checkbox.

<form action="InterestForm.cfm" method="post" name="Form">
<table width="100" border=1 bordercolor="000000" cellpadding=0 cellspacing=0 bgcolor="AFCEE2">
      <tr>
            <td>
                  <table>
                  <tr>
                  <td>
                  <input type ="checkbox" name="IntData" value="0" onClick="int_onchange()" <CFIF isdefined("session.intdata")> Checked</cfif>>
                  </td>
                  <td align="center" >Data
                  </td>
                  </tr>
                  <tr>
                  <td>
                  <input type ="checkbox" name="IntPeople" value="0" onClick="int_onchange()" <CFIF isdefined("client.intpeople")> Checked</cfif>>
                  </td>
                  <td align="center">People
                  </td>
                  </tr>
                  <tr>
                  <td>
                  <input type ="checkbox" name="IntThings" value="0" onClick="int_onchange()" <CFIF isdefined("client.intthings")> Checked</cfif>>
                  </td>
                  <td align="center">Things
                  </td>
                  </tr>
                  </table>
            </td>
      </tr>
</table>
</form>

If there is more information that you need, please let me know.

Thanks,

Tobin      
TobinLewisAsked:
Who is Participating?
 
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0
 
pinaldaveCommented:
Hi TobinLewis,
 
how about trying this StructClear(session.intdata);

Regards,
---Pinal
0
 
TobinLewisAuthor Commented:
Hi,

When I tried StructClear(session.intdata) I received the following error.

An error occurred while evaluating the expression:

StructClear(session.intdata)

Error near line 26, column 9.
--------------------------------------------------------------------------------

Cannot convert given value to a struct. Please check the validity of the expression

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
pinaldaveCommented:
StructClear(session) if you do this compolite structure will be cleared.
0
 
TobinLewisAuthor Commented:
Hi,

I ended up trying the same code that I started with and it seems to be working now.

<CFIF isdefined("url.keepInt") and isdefined("session.intdata")>
      <CFELSEIF not isdefined("form.intdata") and isdefined("session.intdata")>
      <cflock timeout="30" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
            <CFSET StructDelete(session,"intdata")>
      </cflock>
</cfif>

Thanks for your help.

Tobin
0
 
pinaldaveCommented:
=)
0
 
Tacobell777Commented:
Do not use StructClear(session.intdata), its actually structClear( session )
because it clears the whole session scope including CFTOKEN etc.. use structDelete as you have it..

Best thing to do is set everything in another structure, example;

<cfset session.savedData = structNew() />
<cfset session.savedData.something1 = "some data 1" />
<cfset session.savedData.something2 = "some data 2" />
<cfset session.savedData.something3 = "some data 3" />

You can call it like #session.savedData.something3# and you can delete everything with one line of code
<cfset structDelete( session, "savedData" ) />

Having said all that, saving search criteria in the session scope is not a good idea at all, its best to pass this on via the form scope.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.