Skip to main content
myCharlie
Inspiring
June 4, 2015
Question

Using and accessing session variable

  • June 4, 2015
  • 1 reply
  • 445 views

I have found this page, Adobe ColdFusion 9 * Configuring and using session variables, but I do not know if the way I'm using is correct. In the contact us page, I set the session variable to 1 (for yes the user has turned off java script). In the submission-success.cfm, I tried this:

<cfif #session.EmailSuccess# eq 1>

  <cfif (form.mailto is not "" AND form.mailfrom is not "" AND form.message is not "" AND form.name is not "")>

  <cfset session.myweb.email.success = "true">

  <cfmail to = "#form.mailto#" from = "#form.mailfrom#" subject = "Inquiry from Contact Us Form by #form.name#" server="smtp.myweb.com" port="25" type="html">

  <cfoutput>

  <p>This message was sent by an automatic mailer by #form.name#:</p>

  <p>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =<p>

  <p>#form.message#</p>

  <p><cfif structkeyexists(form, "phone")>Phone: #form.phone#</cfif></p>

  </cfoutput>

  </cfmail>

  <cfelse>

  <cfset session.uwec.email.success="false"> 

  <cfset session.uwec.email.failmsg="Please Submit with reCaptcha">

  </cfif>

</cfif>

The email was never sent. Any suggestion is much appreciated.

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    June 4, 2015

    You could simply check whether the conditions for sending e-mail were met. You could do so by placing the following underneath your code block:

    <p>Check:</p>

    session.emailSuccess = <cfoutput>#session.emailSuccess#</cfoutput><br>

    <cfdump var="#form#" label="form">