?
Solved

Deleting Session Variables with Checkbox - 500 points

Posted on 2004-11-01
8
Medium Priority
?
196 Views
Last Modified: 2013-12-24
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      
0
Comment
Question by:TobinLewis
7 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 12466337
Hi TobinLewis,
 
how about trying this StructClear(session.intdata);

Regards,
---Pinal
0
 

Author Comment

by:TobinLewis
ID: 12466695
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
 
LVL 21

Expert Comment

by:pinaldave
ID: 12466709
StructClear(session) if you do this compolite structure will be cleared.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 

Author Comment

by:TobinLewis
ID: 12466752
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
 
LVL 21

Expert Comment

by:pinaldave
ID: 12466765
=)
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 12467496
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
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12747368
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Media Temple is thrilled to announce the launch of our new Partner Program, specifically designed to empower digital agencies and adtech platforms by offering white-glove support and exclusive hosting enhancements to optimize their sites and their c…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question