Skip to main content
October 24, 2008
Question

Application.cfm confusion

  • October 24, 2008
  • 2 replies
  • 333 views
Morning.

I have a homegrown application.cfm file that works ok... It does what I want it to for the most part. However there is one minor issue with it and I cannot figure out what's going on.

I'm attaching a duplicate of Application.cfm with a different name and was hoping someone could tell me what the "insert_start" query continues to execute each time a page is loaded. I wrote this file thinking that it would execute once so I can determine a user's start time in the app.

CFMX WACK explained that once a user is logged in with cfloginuser the code inside the cflogin tag would not execute... that doesn't seem to be the case.

The file I'm using does block users when they aren't logged in and if a user has cookies on their machine it will log them in. However now I need to make sure the start time is tracked only at the start of their session and not each time a page loads.
    This topic has been closed for replies.

    2 replies

    October 24, 2008
    Ok I did something similar...

    <cfparam name="SESSION.id" default="no" type="string">
    <cfif #SESSION.id# EQ "no">

    execute the insert

    </cfif>

    It's working now.

    Thanks!
    Inspiring
    October 24, 2008
    Just put this around
    <cfif NOT #isdefined(session.id)#>

    this
    <cfset SESSION.is_logged_in="yes">
    <cfset SESSION.start_time='#LSDateFormat(Now(), "YYYY-MM-DD")# #LSTimeFormat(Now(), "HH:MM:SS")#'>
    <cfset SESSION.id='#get_user_via_cookies.id#'>
    <cfset SESSION.username='#get_user_via_cookies.username#'>

    <!--- Insert login record --->
    <cfquery name="insert_start" datasource="testdb">
    INSERT INTO login_table
    (id,user_login_time)
    VALUES
    ('#SESSION.id#','#SESSION.start_time#')
    </cfquery>

    <cfquery name="get_insert_record" datasource="testdb" maxrows="1">
    SELECT id FROM login_table ORDER BY id DESC
    </cfquery>

    <cfset valid_login_id = '#get_insert_record.id#'>
    </cfif> Text