Hi Justing, thanks!
I am just trying to get the application to work on my localhost and to transfer 
to another host.
<!--- Application.cfm--->
<cfapplication 
  name="MyPortal" 
  clientmanagement="Yes"
  sessionmanagement="Yes" 
  setclientcookies="Yes"
  sessiontimeout="#CreateTimeSpan(0, 0, 30, 0)#"
  applicationtimeout="#CreateTimeSpan(0, 0, 30, 0)#">
  
<!--- Check to see if the application has been initialized. If not, set the
      necessary application variables and initialize the app --->
<cflock timeout="30" throwontimeout="No" type="ReadOnly" scope="Application">
  <cfset IsInitialized = IsDefined('application.Initialized')>
</cflock>

<cfif not IsInitialized>
  <cflock type="Exclusive" scope="Application" timeout="10">
    <cfif not IsDefined('application.Initialized')>
      <cfset application.DSN ="nutrients">
      <cfset application.AdminEmail = "[email protected]">
      <cfset application.Initialized = true>
    </cfif>
  </cflock>
</cfif>

<!--- set default values for client variables --->
<cfparam name="client.Email" default="Yes">
<cfparam name="client.Stocks" default="Yes">
<cfparam name="client.Tips" default="Yes">
<cfparam name="client.Bookmarks" default="Yes">
<cfparam name="client.BGColor" default="FFFFFF">
<cfparam name="client.FontFace" default="Arial">
<cfparam name="client.HeaderFontColor" default="000000">
<cfparam name="client.HeaderBGColor" default="6666FF">
<cfparam name="client.FontColor" default="000000">

<!--- If the user clicked the logout link, log them out --->
<cfif IsDefined("URL.Logout")>
  <!--- Log out the user --->
  <cflogout>
  
  <cfset URL.Message="Thank you for logging out. Please visit again soon!">
</cfif>

<cflogin idletimeout="1800" applicationtoken="MyPortal">
  <!--- If the cflogin structure does not exist, send the user to the login 
form. --->
  <cfif not IsDefined("cflogin")>
    <!--- if the user is trying to register, let them --->
    <cfif CGI.script_name is not "/portal/registration.cfm">
      <cfinclude template="login.cfm">
      <cfabort>
    </cfif>
    <!--- Validate the user and assign roles --->
  <cfelse>
    <!--- If for some reason username or password is blank, send the user back
          to the login form. --->
    <cfif cflogin.Name is "" or cflogin.Password is "">
      <cfset URL.Message = "You must enter text in both the Username and 
Password fields">
      <cfinclude template="login.cfm">
      <cfabort>
      <!--- Perform the user validation --->
    <cfelse>
      <cfquery name="ValidateUser" datasource="nutrients">
        SELECT Name, Salt, Password, Roles
        FROM users
        WHERE Username = <cfqueryparam value="#cflogin.Name#" 
cfsqltype="CF_SQL_VARCHAR" maxlength="255">
      </cfquery>
      
      <!--- If the username and salted hashed password match, the user is
            authenticated and their role(s) assigned --->
      <cfif (ValidateUser.RecordCount) and (ValidateUser.Password is 
Hash(ValidateUser.Salt & cflogin.Password))>
        <!--- If the user has no assigned roles, assign them to the generic 
"user" role. --->
        <cfif ValidateUser.Roles is "">
          <cfset ValidateUser.Roles = "User">
        </cfif>
        
        <cfloginuser name="#cflogin.Name#" password="#cflogin.Password#" 
roles="#ValidateUser.Roles#">
        
        <cflock name="sLogin_Lock" timeout="30" type="Exclusive">
          <cfset session.Name = ValidateUser.Name>
        </cflock>

        <!--- If save username box is checked, set cookie --->
        <cfif IsDefined('form.SaveUsername')>
          <cfcookie name="Username" value="#cflogin.Name#">
        </cfif>
      <cfelse>
        <cfset URL.Message = "Invalid Login. Please Try Again">
        <cfinclude template="login.cfm">
        <cfabort>
      </cfif>
    </cfif>
  </cfif>
</cflogin>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5504
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to