1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.
  2. Better Analytics for WordPress Get It Free

Coldfusion: How to create an open forum to my website?

Discussion in 'Programming' started by lespaul00, Nov 14, 2007.

  1. #1
    Hello,

    I have a website with a number of different Recipes. I want to either:

    1. Add one big open forum to my website, where people can talk about any recipe on the site, add new threads, etc.

    2. Or, Have a small forum for each recipe (located on each recipe's page).

    I guess I can get it to display from my database, and have people's responses added to my database... but I guess, is there a recommended format someone has for a website forum?

    Thanks
     
    lespaul00, Nov 14, 2007 IP
  2. unitedlocalbands

    unitedlocalbands Peon

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you want the users to have to log in? Like have a loginid and a password?
     
    unitedlocalbands, Nov 14, 2007 IP
  3. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I guess it would be helpful for this feature.
     
    lespaul00, Nov 14, 2007 IP
  4. unitedlocalbands

    unitedlocalbands Peon

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Do you know how to set up an (application.cfm) file? This will initialize the cookies and handel the user logging in.
     
    unitedlocalbands, Nov 14, 2007 IP
  5. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    No I do not. Can you please explain?
     
    lespaul00, Nov 15, 2007 IP
  6. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Also, with a username and password, you'd then be able to regulate how many times an individual votes for something on your website, correct? For instance, when submitting a form to add a vote to your database:

    If "username" RATE present for OBJECT_ID = 5,

    You already submitted a rating!

    If else...

    ... voting script...
     
    lespaul00, Nov 15, 2007 IP
  7. unitedlocalbands

    unitedlocalbands Peon

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    This is very true and there are a number of ways to control how many times a user can vote.

    So Lets get started.

    You will need to set a table to store your users information.

    Think about what info you will need. Things like firstname, lastname, date they signed up, password, username, userid,

    For the application file you will need to create a new file called "application.cfm". Place it in the same folder as your home page.

    Here are the tags you will need to get your application running.
    It would be a good idea to maybe research this type of file either by getting a coldfusion book by like Ben Forta or Ramond Camden, or just look around on the internet. Theres a lot you can do with the application file. Including error handeling.

    You can copy and paste this code to the application file.

    
    <cfapplication name="user_loginid"  clientmanagement="yes" clientstorage="cookie">
    
    <!--- Initialize application varibles --->
    <cfparam name="client.pos" default="">
    <cfparam name="client.user_loginid" default="">
    <cfparam name="client.userid" default="">
    <cfparam name="client.date" default="">
    <cfparam name="client.time" default="">
    <cfparam name="client.signtime" default="0">
    <cfset REQUEST.sitename = "">
    <cfset APPLICATION.companyname = "">
    <cfset APPLICATION.dataSource = "">
    <cfset dbdsn = ""> 
    <cfset dbuser = "">
    <cfset dbpw = "">
    
    
    Code (markup):
    Not every cfparam tag in needed, these are just some of the variables I use.
    If your database is password protected then you will have to tell the application file the username and password to access it.

    
    
    <cfset dbdsn="your dsn">
    <cfset dbuser="database username">
    <cfset dbpw="database password">
    
    Code (markup):
    Once you have the application file setup you can start to build the code to allow the users to register.

    For this You will need a form to collect the information in order to register to store in the table.

    You will need another form to allow them to submit their login information. Then coldfusion will look to see if they are in the database or not.

    If they are, then they get to go to the protected pages. if not it should return a message to them that they did not enter the correct information or they are not registered.
     
    unitedlocalbands, Nov 15, 2007 IP
  8. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks for the information!

    1. Is it a smart idea to have my database password protected?

    2. I guess I don't need the username/password login for users to reach "protected pages", however, I would like it to limit someone from voting on something more than once. I have the voting capability all set up, I just need to find a way to limit a user from voting on a particular object_id twice.

    3. Also, I'd like to have a capable for people to submit images to my website. I don't know if I should have a form, where they can upload an image? If so, i'd like to add a checkbox (that is mandatory to check before submitting), that says "this is my own image" or something of that sort. Or, I don't know if it's wiser, and easier, to just have them send images to an email address. (because I don't know how it would work to upload images to my MS Access database).

    4. And finally, with the username/password, creating the opportunity for forum messages to be posted on each page (which seems like it should be relatively easy... just have it save to the database, then simply have a cfoutput to display all the results - and order by date). Which brings me to another question, how can you add in a "date submitted" field for a form?
     
    lespaul00, Nov 16, 2007 IP
  9. unitedlocalbands

    unitedlocalbands Peon

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    1. I dont think it hurts to password protect your database. In my case i didnt password protect my Ms Access database, but when I switched to MySql You have to have a password because MySql Lives on a protected server on the internet. So thats the only way to retrieve your data.

    2. You can use the application.cfm file to create a cookie that will tell your server if the user is logged in. Then you can use some code like:

    
    <CFSET x = Trim(#client.userid#)>
    <cfif len(#x#) LTE 0>
    	<CFLOCATION URL="index.cfm">
    </CFif>
    
    Code (markup):
    If they havent logged in they will be directed to the login page.

    3. I wanted the same, to let user upload images to my server. I havent yet developed this code because I'm not sure the best way to do this,

    What i do and again I have heard this is not the best way to do it, but I just let the user store the url path to the image that they want to add.

    So if they have a photobucket account then they just get the code from photobucket and add it to my page. Then I query the database for the url and put it into a <img> tag. Lots of people tell me this is really inefficient but it seems to be working fine. And I dont have to let people upload any files to my server.

    i.e.
    
    <img src="http://www.yourimage.com"/>
    
    Code (markup):
    4. I have spent a lot of time getting the data to work right on my website.
    ColdFusion has a tag to output the current data and time in UTC formate.

    Coverting the utc ( Universal time Code) to the local time of the person viweing it is the trick.

    ms access has a date/time data type you can use in the table to store the time stamp.

    
    <cfoutput>#utcDate#</cfoutput>
    
    Code (markup):
    this code will out put the time & date in "UTC" then you will have to convert UTC to the local time of the user.

    this is a challange because how do you determin what time zone the user is in.

    What i did... and you know what I going to say...

    I make the user set their own time zone so that the time appears correctly to them when they log in.

    If they dont select the correct time zone the they just see the UTC time and date which is about 8 hours head of us west coasters.
     
    unitedlocalbands, Nov 16, 2007 IP
  10. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    This code in the application.cfm page?


    Also, how is the "login form" created to be integrated into the application.cfm page? (i.e. how does a user log in?)
     
    lespaul00, Dec 18, 2007 IP
  11. unitedlocalbands

    unitedlocalbands Peon

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Are you running CFMX7? If so theres a better way to set up the application.cfm page. CfStarlight and I have a pretty good thread going on how to set it up as a application.cfc instead of .cfm

    Any way...

    All you need is a simple form with a userid field and a password field.

    
    
    <form action="" method="post">
     Userid<br/>
    <input type="text" name="userid">
    Password<br/>
    <input type="password" name="password">
    </form>
    
    
    Code (markup):
    Then they submit this form to your action page where you have your SQL.

    Here is where you check to see if they are a user and that they have entered the correct information
    
    
    <cfquery datasource="" name="user_check">
    SELECT USERID, PASSWORD
    FROM WHATEVER TABLE
    WHERE USERID = '#FORM.USERID#' AND PASSWORD = '#FORM.PASSWORD#'
    </cfquery>
    
    
    Code (markup):
    Now if they pass the check thne you can set their session variable and pass them to their "profile manager" page.

    
    
    <cfif user_check.recordcount = 1>
    <cfset session.userid = #form.userid#>
    <cflocation url="whateverpage.cfm">
    
    <cfelse>
    <cflocation url="loginpage.cfm">
    
    </cfif>
    
    
    Code (markup):
    These are just some basic examples to get started. They really need more work. but if you really want to make this happen then lets make sure your application.cfc file is setup correctly.

    Heres a link to the thread CfStarlight and i created about the application file.

    http://forums.digitalpoint.com/showthread.php?t=591201

    Check it out and i'll ehlp you get it set up.

    talk to you soon.
     
    unitedlocalbands, Dec 18, 2007 IP
  12. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Awesome!!! Thanks. I will look over it in detail tomorrow...


    it will give me good reading material at work :p



    I have one other question (but if it's answered in the other thread, don't bother).

    But how about setting up a "registration" page?

    I guess it would include a simple form that would use the INSERT INTO SQL statement.

    I will look over the thread and post tomorrow. Thanks again.
     
    lespaul00, Dec 18, 2007 IP
  13. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Do you know of any good websites that walk through, step by step, how to use application.cfc, as well as the different functions it's used for?

    I looked over the other thread. It seems like you have a pretty good conversation going on, but as of now, it's over my head.

    I do understand the simple login.cfm page:

    <form method="post" action="LoginForm.cfm">
    	Test UserID <input type="text" name="userID">
    	Test Password <input type="text" name="userPassword">
    	<input type="submit">
    </form>
    
    
    [COLOR="Red"]<!--- simulating a login here ---->
    <cfif IsDefined('form.userID')>
    	<!--- assign user id to session variable --->
    	<cfset session.UserID = form.userID>
    	<!--- record login in database --->
    	<cfquery datasource="MyDatabase" name="last_login">
    		INSERT INTO User_LOGIN (UserID, Last_Login_Date, OnLine)
    		VALUES ('#session.UserID#', #createODBCDateTime(now())#, '1' )
    	</cfquery>
    	<!--- increment online count --->
    	<cflock name="OnLineNowLock" type="exclusive" timeout="10">
    		<cfset application.onlinenow = application.onlinenow + 1>	
    	</cflock>
    </cfif>[/COLOR]
    
    Code (markup):
    However, I guess CFstarlight added the red portion as a sort of simulation test?

    But, after this form is submitted, what would the LoginForm.cfm page look like? Something like this?

    <cfquery datasource="mydatasource" name="user_check">
    SELECT USERID, UserPassword
    FROM TBLUSER
    WHERE USERID = '#FORM.USERID#' AND UserPassword = '#FORM.UserPassword#'
    </cfquery>
    
    
    <cfif user_check.recordcount = 1>
    <cfset session.userid = #form.userid#>
    <cflocation url="whateverpage.cfm">
    
    <cfelse>
    <cflocation url="login.cfm">
    
    </cfif>
    
    Code (markup):



    Then, here comes the portion I need to learn about - the application.cfc page:

    <cfcomponent output="true">
        <cfset this.name="userid">
        <cfset this.clientStorage = "cookie">
        <cfset this.setClientCookies = "yes">
        <cfset this.sessionmanagement="yes"> 
        <cfset this.sessiontimeout=CreateTimeSpan(0,0,0,10)>
    	
    	<cffunction name="onApplicationStart">
    		Calling OnApplicationStart<br>
    		<cfset application.onlinenow = 0>
    	</cffunction>
    	
        <cffunction name="OnSessionStart" returntype="void">
    		Calling OnSessionStart<br>
        </cffunction>
        
        <cffunction name="OnRequestStart">
    	 	<cfargument type="String" name="targetPage" required="true"/>	
    		Calling OnRequestStart<br>
    		<cfset REQUEST.sitename = "Bla">
    		<cfset REQUEST.companyname = "Bla">
    		<cfset REQUEST.dataSource = "Bla">
    		<cfset dbdsn = "Bla"> 
    		<cfset dbuser = "Bla">
    		<cfset dbpw = "Bla">
    	</cffunction>
        
    <cffunction name="onSessionEnd">
      	<cfargument name="sessionScope" type="struct" required="true">
        <cfargument name="appScope" type="struct" required="false">
          
    	<cfset var last_login = "">
    
    	<!--- if this is a logged in user, record their log out --->	
    	<cfif structKeyExists(arguments.sessionScope, "userID")>
    		<cftry>
    			<cfquery datasource="MyDatabase" name="last_login">
    				UPDATE 	USER_LOGIN
    				SET 	LAST_LOGIN_DATE = #CreateODBCDateTime(NOW())#,
       						ONLINE = '0' 
    	    		WHERE 	USERID = '#arguments.SessionScope.USERID#'
    				AND		ONLINE = '1'
    			</cfquery>
    
    		   	<cflock type="exclusive" name="OnLineNowLock" timeout="10">
    				<cfset arguments.appScope.onlinenow = arguments.appScope.onlinenow - 1>
    			</cflock>
    
    			<cflog file="OnSessionEndLog" text="SUCCESS Logged out userID #arguments.SessionScope.USERID# at #now()#">
    			<cfcatch>
    				<cflog file="OnSessionEndLog" text="ERROR logging out userID #arguments.SessionScope.USERID# at #now()#">
    			</cfcatch>
    		</cftry>
    	<cfelse>
    		<cflog file="OnSessionEndLog" text="Not a logged in user at #now()#">
    	</cfif>
    </cffunction>
    </cfcomponent>
    
    Code (markup):


    I guess I will end my long post with a review of my goals (which I believe can all be accomplished using the application.cfc coding):

    1. Allow for users to "register" on my site (i.e. get a username and password... and insert other information like gender, real name, email address, etc.)
    2. Allow for users to "log in" to my site with their registered user name and password.
    3. Restrict voting on my website only to those with a user name and password (and are logged in).
    4. Create a forum on each of my pages where people can post responses, etc.
     
    lespaul00, Dec 19, 2007 IP
  14. unitedlocalbands

    unitedlocalbands Peon

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #14
    When I get home tonight I will post you my application.cfc file because it has changed a little. Also I will show what each section is used for.

    You are on the right path.

    For now you can work on these things.

    1) Set up your registraion form with all the fields you need to collect the the desiered information.

    2) build an action page to handle the registration form data... i.e. validate the information, and submit it to the database table.

    3) build the table to hold each users information.

    4) build login form & login action page. i.e validate the information and direct user to a secured page.

    Did you say you were using CFMX7?

    Ok, I'll be back later tonight.
     
    unitedlocalbands, Dec 19, 2007 IP
  15. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    lespaul00, Dec 19, 2007 IP
  16. unitedlocalbands

    unitedlocalbands Peon

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Thats it, It's loaded with a lot of great info, but its a little over my head. I just started learning how to program a little over a year ago. I picked CFML because it was the easiest to setup with dreamweaver.

    Anyway, I will go get my aplication.cfc file
     
    unitedlocalbands, Dec 19, 2007 IP
  17. unitedlocalbands

    unitedlocalbands Peon

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #17
    OK here it is. piece by piece:


    This first part sets up how the application stores / handles variables.

    The word "this" refers to the application.

    So for my application I have turned on client management, session management, created a sessiontimout, and set the client storage to cookie.

    Now that I have started to use session managment, I'm starting to phase out all the client variables. I want to try to stop using it all together. Unless you have a reason to use client variables, you might want leave that part out. I just didn't know any better.
    Also I have setup an error handler so when an error does ocoure it doesn't show it to the user, they just see a template I built. It will send the debug page to me via email.
    
    <cfcomponent output="no"> 
             <cfset this.name="userid">
             <cfset this.clientmanagement="yes"> 
             <cfset this.clientstorage="cookie">
             <cfset this.sessionmanagement="yes"> 
             <cfset this.sessiontimeout=CreateTimeSpan(0,0,5,30)>
    	     
    	<cferror type="exception" mailto="me@me.net" template="errorexception.cfm">
    
    Code (markup):

    Here is the OnApplicationStart method. This runs when the application starts up. This is where I set application variables. These variables are for the entire site to use. I only have one application variable I use now. This is so I can track how many people are logged in at any given time.
    
        <cffunction name="onApplicationStart">
    		
    		<cfset application.onlinenow = 0>
            
            
    	</cffunction>
    
    Code (markup):
    OnSessionStart: Not using this one yet. I'm not sure what to use it for just yet. But this one runs when the session first starts

    
        <cffunction name="OnSessionStart" returntype="void">
        
        </cffunction>
    
    Code (markup):
    OnRequestStart runs when a page is requested. The cfargument is required. Not sure why, but you do need it. Here is where I tell the application things like the database source, initialize client variables(which I'm getting rid of), database username & password... Also you can inclued a header for everypage so that you only have to build one header and it will show on every page.

    
     <cffunction name="OnRequestStart">
    	 	<cfargument type="String" name="targetPage" required="true"/>	
    
              <cfset client.userid = "">         
             <cfset application.dataSource = "your datasource">
             <cfset dbdsn = "database name"> 
             <cfset dbuser = "database username">
             <cfset dbpw = "database password">
             <cfinclude template="siteheader.cfm">
    		 
            <cfreturn true>
    </cffunction>
    
    Code (markup):
    OnSessionEnd is where I clean things up. This runs when the session times out. Again the two arguments are required. Inorder to access your application variables or your session variables , you have to use these argument. Then if you what to access these variavles you use (arguments.sessionscope, "variablenamehere") instead of session.variablenamehere. Same thing with the application variables.
    	   
         
         <cffunction name="onSessionEnd">
      	<cfargument name="sessionScope" type="struct" required="true">
        <cfargument name="appScope" type="struct" required="false">
          
    	<cfset var last_login = "">
    
    	<!--- if this is a logged in user, record their log out --->	
    	<cfif structKeyExists(arguments.sessionScope, "userID")>
    		
    			<cfquery datasource="datasourcename" name="last_login">
    				UPDATE 	USER_LOGIN
    				SET 	LAST_LOGIN_DATE = #CreateODBCDateTime(NOW())#,
       						ONLINE = '0' 
    	    		WHERE 	USERID = '#arguments.SessionScope.USERID#'
    				AND		ONLINE = '1'
    			</cfquery>
    
    		   	<cflock type="exclusive" name="OnLineNowLock" timeout="3">
    				<cfset arguments.appScope.onlinenow = arguments.appScope.onlinenow - 1>
    			</cflock>
    
    	</cfif>
    </cffunction>
    </cfcomponent>
    
    Code (markup):
    A lot of info I know, but take it slow and ask pleanty of questions. I'll do my best to help but I'm still learning all of this too.

    Good luck.

    James,
     
    unitedlocalbands, Dec 19, 2007 IP
  18. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Thanks for the great info! I haven't forgotten about this post... things just have been busy around the holidays, and I had a lot of information to digest!

    I purchased that book. I now know where all this is coming from. But I haven't read the sessions portion yet. Plus, I already have a Dreamweaver template for all my pages, so I'm just going to ignore the header in the application.cfc.

    I have some questions on the code. Here I go!!!

    Q1:
    <cfcomponent output="no"> 
    Code (markup):
    What does this do?

    Q2:
    <cferror type="exception" mailto="me@me.net" template="errorexception.cfm">
    Code (markup):
    What does your errorexception.cfm look like?



    Q3:
    I want to create a "recipe of the day" on my page... so I need to create a variable that increments up by 1 each day... starting with the day I begin this. So, if I get this up on February 1, 2008, I want that to begin with record 1 in my database. February 2 would then be record 2, and so on for... say... 1000 records. How can I do this? In here?

        <cffunction name="onApplicationStart">
    		
    		<cfset application.onlinenow = 0>
            
            
    	</cffunction>
    Code (markup):




    Q4:
        <cffunction name="OnSessionStart" returntype="void">
        
        </cffunction>
    Code (markup):
    Is this used when you want to have user specific data? Say, a user logs in, and I want to show them what they chose as their "favorite recipes". Is this where these variables would be defined (aka, pulled from the database)?


    Also, one important thing with my website. I DO NOT want to limit users from browsing my site. I solely want my login to allow people to access their own individual pages (when I get to this point) with their favorite recipes, and to be able to RATE recipes.


    As for your recommendation before:

    I have completed these steps. However, for #1, I would like to have a login block in the upper right hand corner of my website (every page) so a user can log in from any page. Then, once logged in, it instead says "Welcome #user#!"


    Thanks!!!
     
    lespaul00, Jan 4, 2008 IP
  19. unitedlocalbands

    unitedlocalbands Peon

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #19
    A1:

    Im not totally sure about the first question. Maybe because the application.cfc file is not a true component.

    A2:
    The errorexception.cfm file can look anyway you like. It can also contain cfml like if you want it to email you the error.

    heres what mine looks like.

    http://www.unitedlocalbands.com/user_browse/browse_band.cfm?g&ty=band

    A3:
    I have to think about this one. Because you only want this to increment once a day and not everytime the application starts.

    A4:
    You dont want to define and user variables until you have checked their login information.

    I wouldnt put anything in the onsessionstart just yet. You can define the user variables on the same page as your action page where you send the data from the login form.

    A5:

    A simple cfif statment will work:

    
    <cfif StruckExist(Session.Userid) and SESSION.USERID neq "">
    Welcome #firstname#
    <cfelse>
    
    <form action="" methode="">
    <input type="text" name="loginid"/>
    <input type="password" name="password"/>
    <input type="submit"/>
    </form>
    </cfif>
    
    Code (markup):
     
    unitedlocalbands, Jan 4, 2008 IP
  20. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    I have the following for my respective pages:

    My login page (login.cfm)

      <h1>Login</h1>
      <p>Please login below:</p>
    <form method="post" action="loginform.cfm">
    <table width="60%" align="left" cellpadding="0" border="0">
    <tr>
    	<td>
    	  <p>Username:
    	    </p></td>
    	<td>
     	<input type="text" name="username_name">
    	</td>
    </tr>
    <tr>
    	<td>
    	  <p>Password: 	
    	    </p></td>
    <td>
    <input type="text" name="password_pass">
    </td>
    </tr>
    <tr>
    <input type="submit">
    </tr>
    </table>
    </form>
    Code (markup):
    Here is my login_process.cfm page:

      <h1>Login</h1>
    <cfquery datasource="mydatabase" name="user_check">
    SELECT USER_NAME, USER_PASS
    FROM TBLUSER
    WHERE USERID = '#form.username_name#' AND PASS = '#form.password_pass#'
    </cfquery>
    
    
    <cfif user_check.recordcount = 1>
    <cfset session.userid = #form.username_name#>
    <cflocation url="index.cfm">
    
    <cfelse>
    <cflocation url="login.cfm">
    
    </cfif>
    Code (markup):
    And here is my application.cfc:

    
    <cfcomponent output="no"> 
             <cfset this.name="userid">
             <cfset this.clientmanagement="yes"> 
             <cfset this.clientstorage="cookie">
             <cfset this.sessionmanagement="yes"> 
             <cfset this.sessiontimeout=CreateTimeSpan(0,0,5,30)>
    	     
    	<cferror type="exception" mailto="me@me.net" template="errorexception.cfm">
    
    
        <cffunction name="onApplicationStart">
    		
    		<cfset application.onlinenow = 0>
            
            
    	</cffunction>
    
    
        <cffunction name="OnSessionStart" returntype="void">
        
        </cffunction>
    
    <cffunction name="OnRequestStart">
    	 	<cfargument type="String" name="index.cfm" required="true"/>	
    
             <cfset application.dataSource = "mydatabase">
             <cfset dbdsn = "mydatabase"> 
             <cfset dbuser = "database username">
             <cfset dbpw = "database password">
    
    		 
            <cfreturn true>
    </cffunction>
    
         <cffunction name="onSessionEnd">
      	<cfargument name="sessionScope" type="struct" required="true">
        <cfargument name="appScope" type="struct" required="false">
          
    	<cfset var last_login = "">
    
    	<!--- if this is a logged in user, record their log out --->	
    	<cfif structKeyExists(arguments.sessionScope, "userID")>
    		
    			<cfquery datasource="mydatabase" name="last_login">
    				UPDATE 	USER_LOGIN
    				SET 	LAST_LOGIN_DATE = #CreateODBCDateTime(NOW())#,
       						ONLINE = '0' 
    	    		WHERE 	USERID = '#arguments.SessionScope.USERID#'
    				AND		ONLINE = '1'
    			</cfquery>
    
    		   	<cflock type="exclusive" name="OnLineNowLock" timeout="3">
    				<cfset arguments.appScope.onlinenow = arguments.appScope.onlinenow - 1>
    			</cflock>
    
    	</cfif>
    </cffunction>
    </cfcomponent>
    
    
    Code (markup):

    When I try just accessing my index.cfm file, I get the following error:


    How do I correct this?
     
    lespaul00, Jan 4, 2008 IP