Skip to main content
Known Participant
April 9, 2008
Answered

How to share data in cfc files?

  • April 9, 2008
  • 3 replies
  • 390 views
I can save shared data (like dsn) in application.cfm so all the cfm file can read it.

But how to share data in cfc files like application.cfm. I hear application.cfc,may I use it share data in cfc files?

Do you think if it is ok that application.cfm and application.cfc exist in the site?

Thanks

Mark
    This topic has been closed for replies.
    Correct answer Amiable_Penguin15D5
    IIRC, you can't use both. If you have Application.cfm and Application.cfc in the same folder, CF will ignore Application.cfm.

    3 replies

    Amiable_Penguin15D5Correct answer
    Participating Frequently
    April 10, 2008
    IIRC, you can't use both. If you have Application.cfm and Application.cfc in the same folder, CF will ignore Application.cfm.
    Inspiring
    April 10, 2008
    quote:

    Originally posted by: mark416
    I can save shared data (like dsn) in application.cfm so all the cfm file can read it.

    But how to share data in cfc files like application.cfm. I hear application.cfc,may I use it share data in cfc files?

    Do you think if it is ok that application.cfm and application.cfc exist in the site?

    Thanks

    Mark

    Don't use both. Things like a dsn are best defined in the onApplicationStart method of an application.cfc.
    April 9, 2008
    Application.cfc all the way. This has special functions that can execute on certain situations (like every page request).

    If you need a variable available across the whole application, specify it in the application.cfc file. Trying to share variables across the application from functions in a normal .cfc file doesn't make sense as the functions / methods called within it would only exist when they are specifically called.

    Do not use application.cfm any longer if you can.