Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Deleting Session Variables with Checkbox - 500 points

Posted on 2004-11-01
8
Medium Priority
?
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 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
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 

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

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
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…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

618 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