Skip to main content
Participant
October 2, 2010
Question

problem with cflogin

  • October 2, 2010
  • 2 replies
  • 771 views

hello everybody,

I am very new to this forum and cold fusion, actually i first used cold fusion about a week ago so my coding is very basic. What i am trying to achieve is a member login page on my website where users can just enter my site and if they want to login the can press the link "login". i have already created a member register page that it fully working and sends the information that the user enters to my database.

The software i am using is: cold fusion developer edition in dreamweaver, and mysql workbench.

I have already started coding witch i will paste bellow. I have created a cfc for my loginpage.cfm and i am using <cflogin> in the cfc.

Heres all of the code i have created on the memberlogin.cfc file:

<cfcomponent>
<cffunction name="memberlogin" access="public" returntype="void">

<cflogin>
  <cfif IsDefined("form.email")>
            <cfquery datasource="#application.datasource#"
                name="quser">
                    SELECT * FROM members
                    WHERE email='#form.email#'
                    AND password='#form.password#'
     
            </cfquery>
  
   <cfif quser.recordcount IS 1>
           </cfif>
            <cfloginuser name="#quser.email#"
            password="#form.password#"
            roles="#quser.roles#">
          

    </cflogin>

</cffunction>
</cfcomponent>

And here is the code in the top of my login.cfm file:

<cfinvoke
component="Fusionmods.cf.cfc.memberlogin"
method="memberlogin">
</cfinvoke>

The problem i have no idea if i can login, i mean when i look at a email and password from my database and type it in to the login page on my site i have no idea weather i am logged in or not

I was wondering if anybody could tell me how i could add a automatic link so that when a member has sucessfully logged in it takes them to the home page and if they loggin incorrectly the login page appears again??

Thank you.

    This topic has been closed for replies.

    2 replies

    ecobb
    Inspiring
    October 5, 2010

    Read through this and see if it helps.  It's a little outdated (Application.cfm, no CFCs), but it should give you a good overview of cflogin and how to use it in your application. From there you should be able to port the logic over to your CFC.

    http://www.tek-tips.com/faqs.cfm?fid=5186

    Known Participant
    October 2, 2010

    Do members have to log-in to use the site, or do they just need to log-in to get their session registered (much like a forum browser vs forum poster)?

    If you want to login users via the <cflogin> tag, you always want to use the j_username and j_password as the form names.  ColdFusion is built in to listen to any forms passed with those variable names.  Also, the <cflogin> tag should always sit in the application.cfm/cfc page.

    Have you read the "Security CF Applications" tutorial?  That may help.  http://livedocs.adobe.com/coldfusion/8/htmldocs/appSecurity_01.html#1100022

    You can use that as a good start.  In your application page <cflogin> tag, you can define whether or not someone is logged in by using session variables and the built in function #getAuthuser()#.  If you are not logged in, getAuthUser() will return 0.  That is an easy way to tell if someone is logged into the website.