ColdFusion Kinky eCards Update
Posted March 11, 2008 at 11:57 AM by Ben Nadel
Just fixed a small bug in my ColdFusion Kinky eCards Hayden Panettiere demo application. In the OnSessionStart(), I was clearing the session data. However, I was throwing the baby out with the bath water, so to speak, and was actually deleting the CFID and CFTOKEN as well. I am not sure if this was causing any bugs, per say, but I would definitely consider this to be a bad practice. Now, the new code, which can be downloaded from the Kinky eCards Project page has a modified OnSessionStart() event method that restores the CFID and CFTOKEN values after the SESSION scope is cleared:
- <cffunction
- name="OnSessionStart"
- access="public"
- returntype="void"
- output="false"
- hint="Initializes the user's session.">
-
- <!--- Define the local scope. --->
- <cfset var LOCAL = {} />
-
- <!--- Store the use ID / TOKEN values before we clear. --->
- <cfset LOCAL.CFID = SESSION.CFID />
- <cfset LOCAL.CFTOKEN = SESSION.CFTOKEN />
-
- <!---
- Clear the session. We should do this incase we
- are re-initializing.
- --->
- <cfset StructClear( SESSION ) />
-
- <!--- Restore the ID/TOKEN values. --->
- <cfset SESSION.CFID = LOCAL.CFID />
- <cfset SESSION.CFTOKEN = LOCAL.CFTOKEN />
-
- <!---
- Set up a struct to hold the form data. We the need
- the form data so that the user can go back and forth on
- multi-page forms (ex. enter data and preview eCard).
- --->
- <cfset SESSION.FormData = {} />
-
- <!--- Return out. --->
- <cfreturn />
- </cffunction>
Reader Comments
Thanks for info. Excellent article...
Ben, great fix. Thanks a lot!
I'm new here and new to ColdFusion, but i'm a fan of ColdFusion too, thanks for the update, i'm reading the code line by line, hope can get some idea about eCard
Thanks
I'm new here and new to ColdFusion, but i'm a fan of ColdFusion too, thanks for the update, i'm reading the code line by line, hope can get some idea about eCard
Thanks



