ColdFusion Kinky eCards Update

Posted March 11, 2008 at 11:57 AM

Tags: ColdFusion

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:

 Launch code in new window » Download code as text file »

  • <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>

Download Code Snippet ZIP File

Comments (2)  |  Post Comment  |  Ask Ben  |  Permalink  |  Print Page




Adobe ColdFusion 8.0.1 Update - Helping Programmers To Be Signifanctly Less Girlie - Download ColdFusion 8 Update 8.0.1 Now.

Reader Comments

Thanks for info. Excellent article...

Posted by Greg Fortelly on May 17, 2008 at 7:43 AM


Ben, great fix. Thanks a lot!

Posted by Good Joe on Jul 3, 2008 at 3:04 AM


Post Comment  |  Ask Ben


Home   |   Web Log   |   ColdFusion   |   Projects   |   Resume   |   Job Form   |   Search   |   Contact
Epicenter Consulting - Custom Software Solutions for Business Evolution HostMySite.com - The Leader In ColdFusion Hosting