On 1/13/06, Ben Nadel <[EMAIL PROTECTED]> wrote:
>
> I might be wrong here, but in the past, i have had problems with
> StructClear(SESSION) as it deleted the CFID and CFTOKEN. This has caused odd
> behavior in my applications and I know use a method SessionClear(SESSION):
>
>
> for (i in SESSION){
>     if (CompareNoCase(Left(2, i), "CF")){
>         // Safe to delete since it doesnt start with CF
>         StructDelete(SESSION, i);
>     }
> }
>
>
> Of course this only works if you dont have other variables in session
> starting with CF.

This works if you're not using J2EE session variables, although
personally I would explicitly check for CFID and CFTOKEN as the key
names. They will not change between versions, as they're so entrenched
in all versions of ColdFusion, and you remove the possibility of a
developer naming a session variable "CFMYVAR" or something. I would
also add in a check to preserve SESSIONID and URLTOKEN as well in the
event that you switch to J2EE session variables. So a re-factored code
snippet might look like:

for ( i in session ) {
    if ( not listFindNoCase("CFID,CFTOKEN,SESSIONID,URLTOKEN", i) ) {
        // Safe to delete since it's not a built-in CF variable
        structDelete(session, i);
    }
}

Regards,
Dave.


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to