Hi I am looking into developing a login system for a coldfusion site that uses a session variable to determine whether or not the user is logged in. With the way i am doing it i am finding it hard as a novice to understand. My setup is that the form for the username and password is created in a .txt file which is then included and displayed on all pages allowing the user to log in from wherever they are. Can anyone give me a guide and some code which may help me learn how to do this. Thanks tech_dude
Are you using CFMX7? If so you can start here, Heres a list of what you will need, Application.cfc file, Login Form, Registration form, Database table to hold registered users information. Start with building an application.cfc file first. Here is a llink to a search on application.cfc so you can familurize yourself with what it is and how it works. http://www.unitedlocalbands.com/ser...000000;GFNT:0000FF;GIMP:0000FF;FORID:11&hl=en Here is what an example of what a simple application.cfc file looks like, you may use this one to get started <!---Initialize Application Component---> <cfcomponent output="no"> <cfset this.name="[COLOR="Red"]PICK A NAME FOR YOUR APPLICATION[/COLOR]"> <cfset this.clientmanagement="no"> [COLOR="red"]Sessionmanagement must be set to "yes" to use session variables![/COLOR] <cfset this.sessionmanagement="yes"> <cfset this.sessiontimeout=CreateTimeSpan(0,0,10,0)> <!---Code in this section will run when the application starts---> <cffunction name="onApplicationStart"> </cffunction> <!---Code here will run when a session starts ---> <cffunction name="OnSessionStart" returntype="void"> </cffunction> <!---Code here will run when a request happens---> <cffunction name="OnRequestStart"> <cfargument type="String" name="targetPage" required="true"/> <cfreturn true> </cffunction> <!---Code here runs when a session ends---> <cffunction name="onSessionEnd"> <cfargument name="sessionScope" type="struct" required="true"> <cfargument name="appScope" type="struct" required="false"> </cffunction> <!---Code here will run when the request ends---> <cffunction name="onRequestEnd" returnType="void"> <cfargument type="String" name="targetPage" required=true/> </cffunction> </cfcomponent> Code (markup):
Unitedlocalbands will get you up and running on this - or, you could also search this forum for your question. We've discussed this type of a setup before, and it may be of use to check out. Plus, you'll uncover some other additional features.
If you haven't solved the problem yet, here's a Dreamweaver extension that will create the log in and admin sections in coldfusion.