We help IT Professionals succeed at work.
Get Started

question regarding application.cfc

406 Views
Last Modified: 2013-12-24
Hi experts. I have the following application.cfc, but when i login my session does not get populated, i am using the following code:

<cffunction verifyclient="yes" name="onApplicationStart" output="false">
  <cfset Application.configured = 1>
  <cfset Application.datetimeConfigured = TimeFormat(Now(), "hh:mm tt") & "  " & DateFormat(Now(), "mm.dd.yyyy")>
  <cfset Application.currentSessions = 0>
  <!--- Application Addresses --->
  <cfset setLocale("English (US)")>
  <!--- Set the session page encoding --->
  <cfset setencoding("URL", "utf-8")>
  <cfset setencoding("Form", "utf-8")>
  <cfcontent type="text/html; charset=utf-8">
  <cfreturn True>
</cffunction>
<cffunction verifyclient="yes" name="onSessionStart" returntype="void">
  <cfset Session.StaffAuth = StructNew()>
  <cfset Session.StaffAuth.IsLoggedIn = false>
  <cfset Session.StaffAuth.StaffID = "">
  <cfset Session.StaffAuth.StaffName = "">
  <cfset Session.StaffAuth.StaffPermissions = "">
  <cfset Session.SuccessMsg = "">
  <cfset Application.sessionTracker = #StructNew()#>
</cffunction>
<cffunction verifyclient="yes" name="onSessionEnd" returntype="void">
  <cfargument name="SessionScope" required="true">
  <cfscript>
      StructClear(session);
      StructClear(cookie);
      </cfscript>
</cffunction>

Also my this:

<cfset setLocale("English (US)")>
  <!--- Set the session page encoding --->
  <cfset setencoding("URL", "utf-8")>
  <cfset setencoding("Form", "utf-8")>
  <cfcontent type="text/html; charset=utf-8">

is correct or not as i have added in Application.cfc file


below is the login.cfm page code:

<cfif login.RecordCount EQ 1>
      <cfif login.Disabled IS 0>
        <cfset ErrorMsg = "You account is currently inactive.">
        <cfset ErrorFlag = true>
        <cfelse>
        <cflock scope="session" type="exclusive" timeout="10">
          <cfset Session.StaffAuth = StructNew()>
          <cfset Session.StaffAuth.IsLoggedIn = true>
          <cfset Session.StaffAuth.StaffID = login.ID>
          <cfset Session.StaffAuth.StaffName = "#login.nadmin# #login.pwd#">
          <cfset Session.StaffAuth.StaffPermissions = login.role>
          <cfset Session.SuccessMsg = "">
          <!--- Declare variable in session scope for later use --->
        </cflock>
blah blah extra code goes down under.......

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 4 Answers and 15 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE