Skip to main content
Inspiring
July 12, 2006
Answered

Cold Fusion Build-In Variable

  • July 12, 2006
  • 5 replies
  • 660 views


Good Day:

Tx in advance for answering my question....

I'm a new user in CF. Looking for some siple output in CLIENT.variable. For instance, I just would like code a simple output of CLIENT.LastVisit

All the example I searched give me something:
<cfoutput>
Welcome back!!! Your last
visit was on #DateFormat(Client.LastVisit)#.
</cfoutput>
which return me null. To sucessfully use it, I somehow believe i need to use it together with the <cfaplication>. May I have something as simple as possible just to see the result?


On top of that, if I were to futher use the CLIENT.CFID, I believe i should use the <cfset> to set it? How? Pls reply me something as simple as possible like:
<cfset CLIENT.CFID>???
<cfoutput>#CLIENT.CFID</cfoutput>

On the CF (or I'm acceing throuhg Dreamweaver), I can find a simple help example for those coding. I belive it should have. In future, how and hwere is the best way to just view some coding example whenever I encounter problem? I even when to the CF Admin - description there is good but no example, some on the Code Panel...

tx!
    This topic has been closed for replies.
    Correct answer ONG_Sam
    Good Day Kevin & Liquid One:

    finally it works by using together with application.cfm and clientmanagement="yes.

    FYI, I'm using CF7...for those who facing the same prob, try the suggestion form this two expert

    yeah yeah

    5 replies

    ONG_SamAuthorCorrect answer
    Inspiring
    July 13, 2006
    Good Day Kevin & Liquid One:

    finally it works by using together with application.cfm and clientmanagement="yes.

    FYI, I'm using CF7...for those who facing the same prob, try the suggestion form this two expert

    yeah yeah
    Participating Frequently
    July 13, 2006
    ONG - If you are using CF7 try making use of the application.cfc

    Here's what you would do to accomplish the same

    <cfcomponent>
    <cfset this.clientManagement = true>

    </cfcomponent>

    By using application.cfc you also have acess to methods like onApplicationStart and End, onSessionStart and End, and onRequestStart and End as well as a few others.

    Inspiring
    July 13, 2006
    I beleive the best way to enable client variables is to do so in the application.cfm file. Just do as my previous post states and create a blank page called application.cfm, and put it in your main directory. Then create one line at the top:
    clientmanagement="yes"
    and then save it.
    After you do that, you should be able to use the built in client.LastVisit variable that Kevin was nice enough to point out (Thanks Kevin).

    Good luck!
    Participating Frequently
    July 13, 2006
    You need to enable it using the <cfapplication> tag or as a varialbe in application.cfc.

    What version of CF are you using and are you using application.cfm or application.cfc
    Participating Frequently
    July 12, 2006
    ONG Sam - Both of the responders are wrong. There is a variable built into the client scope called lastVisit.

    It may help you out volumes to take a look at this page. You too TSB and liquid one.

    http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00001155.htm
    ONG_SamAuthor
    Inspiring
    July 13, 2006
    Good Day Kevin:

    I have read and tried the suggestion your mention on the KBase even before I post this qs but yet I failed to achieve which I strongly believe is due to my lack understanding on CF.

    Tx.
    Inspiring
    July 12, 2006
    There is no variable for last visit built into coldFusion. I think what the example you are using does is once the user logs in then it queries a database and returns a query called client with lastVisit as a field that is returned. This would require you to either create a login for users or create a cookie that can be read when the user returns to the site.

    T
    Inspiring
    July 12, 2006
    Hello, it would be possible to generate a variable like that, using client management.
    First, you would need to either turn on client management in your administrator, or make a file called application.cfm, and put it in main website directory. Ad one line in there that says:
    clientmanagement="yes"
    and then save the file.

    Then when you make your page, you need to set a default as today by using the follow code:
    <CFPARAM name="client.LastVisit" default="unknown">
    <cfif client.LastVisit IS 'unknown'>
    <cfset client.LastVisit = #DateFormat(Now(), "MM/DD/YYYY")#
    </cfif>
    Then, you can use the #client.LastVisit# variable throughout your page, then at the end of your page, you will want to update it to todays date if it already had a date, with the following code:
    <cfset client.LastVisit = #DateFormat(Now(), "MM/DD/YYYY")#
    Make sure its used at the end of your page, and keep in mind that if you use the cflocation tag, the client variables that you try to set on that page will not save properly, so dont use cflocation with pages that have client variables to be safe.
    Have fun!
    Mike
    ONG_SamAuthor
    Inspiring
    July 13, 2006
    Good Day Liquid One:

    Your answer sound very close to my qs....sorry to ask...where's the Client Management? I search through the CF Admin Management but fail to find it?

    tx