Re: Cannot access session variables in a cfc
Some of the dangers to this approach include: the amount of memory allocated to the JVM. If you stuff alot of data into the Application scope, it persists in the JVM allocated memory and it's not available to the rest of the system/application. You really can't change data in the Application scope without having to reload it. I generally use the Application scope for application wide CFC instantiation, the and not actual application wide data. Just my $.02 sas On Thu, Jan 29, 2015 at 11:53 AM, John Pullam jpul...@mcleansystems.com wrote: For what it's worth, the approach of storing a global data item in the application scope seems to be legit according to the documentation. Here's what it said in the CF10 doc: Application variables are a convenient place to store information that all pages of your application might need, no matter which client is running that application. Using application variables, an application could, for example, initialize itself when the first user accesses any page of that application. This information can then remain available indefinitely, thereby avoiding the overhead of repeated initialization. Because the data stored in application variables is available to all pages of an application, and remains available until a specific period of inactivity passes or the ColdFusion server shuts down, application variables are convenient for application-global, persistent data. However, because all clients running an application see the same set of application variables, these variables are not appropriate for client-specific or session-specific information. To target variables for specific clients, use client or session variables. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360042 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
For what it's worth, the approach of storing a global data item in the application scope seems to be legit according to the documentation. Here's what it said in the CF10 doc: Application variables are a convenient place to store information that all pages of your application might need, no matter which client is running that application. Using application variables, an application could, for example, initialize itself when the first user accesses any page of that application. This information can then remain available indefinitely, thereby avoiding the overhead of repeated initialization. Because the data stored in application variables is available to all pages of an application, and remains available until a specific period of inactivity passes or the ColdFusion server shuts down, application variables are convenient for application-global, persistent data. However, because all clients running an application see the same set of application variables, these variables are not appropriate for client-specific or session-specific information. To target variables for specific clients, use client or session variables. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360041 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
+1 On Thu, Jan 29, 2015 at 12:53 PM, Russ Michaels r...@michaels.me.uk wrote: I'll add for the sake of brevity, please don't put application wide cfcs in session scope, as a hosting provider I have seen this kill a server. 5000 users = 5000 instances of the cfc. In most cases using a mapping solves the issues you have with cf not finding the cfc. On Thu, Jan 29, 2015 at 17:00 PM, Scott Stewart webmas...@sstwebworks.com wrote: Some of the dangers to this approach include: the amount of memory allocated to the JVM. If you stuff alot of data into the Application scope, it persists in the JVM allocated memory and it's not available to the rest of the system/application. You really can't change data in the Application scope without having to reload it. I generally use the Application scope for application wide CFC instantiation, the and not actual application wide data. Just my $.02 sas On Thu, Jan 29, 2015 at 11:53 AM, John Pullam jpul...@mcleansystems.com javascript:; wrote: For what it's worth, the approach of storing a global data item in the application scope seems to be legit according to the documentation. Here's what it said in the CF10 doc: Application variables are a convenient place to store information that all pages of your application might need, no matter which client is running that application. Using application variables, an application could, for example, initialize itself when the first user accesses any page of that application. This information can then remain available indefinitely, thereby avoiding the overhead of repeated initialization. Because the data stored in application variables is available to all pages of an application, and remains available until a specific period of inactivity passes or the ColdFusion server shuts down, application variables are convenient for application-global, persistent data. However, because all clients running an application see the same set of application variables, these variables are not appropriate for client-specific or session-specific information. To target variables for specific clients, use client or session variables. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360044 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
I'll add for the sake of brevity, please don't put application wide cfcs in session scope, as a hosting provider I have seen this kill a server. 5000 users = 5000 instances of the cfc. In most cases using a mapping solves the issues you have with cf not finding the cfc. On Thu, Jan 29, 2015 at 17:00 PM, Scott Stewart webmas...@sstwebworks.com wrote: Some of the dangers to this approach include: the amount of memory allocated to the JVM. If you stuff alot of data into the Application scope, it persists in the JVM allocated memory and it's not available to the rest of the system/application. You really can't change data in the Application scope without having to reload it. I generally use the Application scope for application wide CFC instantiation, the and not actual application wide data. Just my $.02 sas On Thu, Jan 29, 2015 at 11:53 AM, John Pullam jpul...@mcleansystems.com javascript:; wrote: For what it's worth, the approach of storing a global data item in the application scope seems to be legit according to the documentation. Here's what it said in the CF10 doc: Application variables are a convenient place to store information that all pages of your application might need, no matter which client is running that application. Using application variables, an application could, for example, initialize itself when the first user accesses any page of that application. This information can then remain available indefinitely, thereby avoiding the overhead of repeated initialization. Because the data stored in application variables is available to all pages of an application, and remains available until a specific period of inactivity passes or the ColdFusion server shuts down, application variables are convenient for application-global, persistent data. However, because all clients running an application see the same set of application variables, these variables are not appropriate for client-specific or session-specific information. To target variables for specific clients, use client or session variables. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360043 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Cannot access session variables in a cfc
Were you using relative paths to the CFCs. That could become hairy if you move things around. I'll generally define a CFC path variable in the application.cfm then use that everywhere. Never had a problem. Of course, this assumes all the CFC's are in the same location. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.118 Direct Line: 516-302-4345 www.aimg.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360023 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Cannot access session variables in a cfc
Can you give us some code examples of how it 'used' to be setup? Where was the CFC saved. Where was the CFC called. How was it called. Etc. Not that fixing the actual problem will set you suddenly into best practices, but it will fix your current headache and then you can follow up with BP later when the fires are out. Thanks, William -- William Seiter -Original Message- From: John Pullam [mailto:jpul...@mcleansystems.com] Sent: Wednesday, January 28, 2015 8:57 AM To: cf-talk Subject: Re: Cannot access session variables in a cfc I know this isn't ideal, but it is a live application and the decision to move the cfc's outside of the doc root was taken because CF was having trouble finding them (for no obvious reason). Code that has worked since CF7 started breaking. So we moved them and this problem began. I am looking for a quick solution for now, knowing that I need to develop a better one. I'm wondering about putting the variable in the Application scope? Do the cfc's have access to that? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360024 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
You will need to pass your session variables as a parameter in order to use them in the CFC, this is best practices anyways. The difficulty is that there a lot of cfc calls and some of them are in bind expressions so the chance of making errors is high. That's why I am so anxious to find one that doesn't make me change a lot of programming. Long term I will opt for a better solution. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360025 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
On Wed, Jan 28, 2015 at 1:57 PM, Robert Harrison rharri...@aimg.com wrote: try adding an Application.cfc in the root physical directory I don't that that will work. It would still be a separate application pool, and I think you need the CFID and CFTOKEN cookies to have session vars. Did a simple test on CF10 and CF8 and this does seem to work. The only identifier for an application is the application name that I'm aware of, so I would guess the first Application.cfc to be called would be the one to initialize the application. Subsequent calls would set the session and application timeouts, thus setting them the same would be a good idea. That being said, Dean's proxy suggestion is probably best, since you would probably want the code to run from either application.cfc. I thought the directory structure might be like this. The proxy would still work, but would probably just need a cfmapping to the app root so the /cfc/application.cfc could find the /app/applicationproxy.cfc. /cfc /app /app/application.cfc ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360035 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
@Dean, Looked into this a bit further on CF10. root - Application.cfc - ApplicationProxy.cfc (extends Application) - cfc-folder - - Application.cfc (extends ApplicationProxy) - - myCFC.cfc This does not work without the cfc/application.cfc having extends=root.ApplicationProxy, where 'root' is a CF mapping. As you said, CF will search from the application root downward on the file system. Since there is an Application.cfc in the cfc folder, it would start there and not find the ApplicationProxy in the directory above. This would work if the actual root directory was cfusion/wwwroot, or maybe if both application.cfc had the same applicationName and the ApplicationProxy was used/cached in /root app somehow before /root/cfc was initialized. If you use a CF mapping the proxy is really not even necessary, as this does work. /cfc/application.cfc - cfcomponent extends=root.application Cheers, Byron On Wed, Jan 28, 2015 at 3:44 PM, Dean Lawrence dean...@gmail.com wrote: Byron, the ApplicationProxy.cfc needs to be in the root directory along with the main Application.cfc. When you extend a CFC, CF will first look in the same directory to see if that CFC exist. If it doesn't CF will start looking for the CFC from the application root down. So by simply adding extends=ApplicationProxy to the Application.cfc within the /cfc directory, CF will find the ApplicationProxy.cfc in the root, which in turn finds the Application.cfc in the root. No mappings are needed. T ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360039 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
Byron, the ApplicationProxy.cfc needs to be in the root directory along with the main Application.cfc. When you extend a CFC, CF will first look in the same directory to see if that CFC exist. If it doesn't CF will start looking for the CFC from the application root down. So by simply adding extends=ApplicationProxy to the Application.cfc within the /cfc directory, CF will find the ApplicationProxy.cfc in the root, which in turn finds the Application.cfc in the root. No mappings are needed. On Wed, Jan 28, 2015 at 3:21 PM, Byron Mann byronos...@gmail.com wrote: On Wed, Jan 28, 2015 at 1:57 PM, Robert Harrison rharri...@aimg.com wrote: try adding an Application.cfc in the root physical directory I don't that that will work. It would still be a separate application pool, and I think you need the CFID and CFTOKEN cookies to have session vars. Did a simple test on CF10 and CF8 and this does seem to work. The only identifier for an application is the application name that I'm aware of, so I would guess the first Application.cfc to be called would be the one to initialize the application. Subsequent calls would set the session and application timeouts, thus setting them the same would be a good idea. That being said, Dean's proxy suggestion is probably best, since you would probably want the code to run from either application.cfc. I thought the directory structure might be like this. The proxy would still work, but would probably just need a cfmapping to the app root so the /cfc/application.cfc could find the /app/applicationproxy.cfc. /cfc /app /app/application.cfc ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360036 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
Hmm, that's odd as I use that setup on numerous sites and I never have to map the applicationproxy. I am currently using it on both ACF 10 and 11, but I started using this around 8 or 9 and haven't changed it for new version. I don't believe that you could use the root.(dot) notation in 8 or 9, which if I remember correctly, predicated the use of the proxy. Every site is also housed in completely different directories, nowhere near the cfusion/wwwroot directory, so I am not sure why it is didn't work for you as well. Anyway, thanks for the additional info regarding cutting out the proxy step. On Wed, Jan 28, 2015 at 4:54 PM, Byron Mann byronos...@gmail.com wrote: @Dean, Looked into this a bit further on CF10. root - Application.cfc - ApplicationProxy.cfc (extends Application) - cfc-folder - - Application.cfc (extends ApplicationProxy) - - myCFC.cfc This does not work without the cfc/application.cfc having extends=root.ApplicationProxy, where 'root' is a CF mapping. As you said, CF will search from the application root downward on the file system. Since there is an Application.cfc in the cfc folder, it would start there and not find the ApplicationProxy in the directory above. This would work if the actual root directory was cfusion/wwwroot, or maybe if both application.cfc had the same applicationName and the ApplicationProxy was used/cached in /root app somehow before /root/cfc was initialized. If you use a CF mapping the proxy is really not even necessary, as this does work. /cfc/application.cfc - cfcomponent extends=root.application Cheers, Byron On Wed, Jan 28, 2015 at 3:44 PM, Dean Lawrence dean...@gmail.com wrote: Byron, the ApplicationProxy.cfc needs to be in the root directory along with the main Application.cfc. When you extend a CFC, CF will first look in the same directory to see if that CFC exist. If it doesn't CF will start looking for the CFC from the application root down. So by simply adding extends=ApplicationProxy to the Application.cfc within the /cfc directory, CF will find the ApplicationProxy.cfc in the root, which in turn finds the Application.cfc in the root. No mappings are needed. T ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360040 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Cannot access session variables in a cfc
My app is running in a CF10 system and since I moved my cfc's out of the document root, they are losing access to the session variables. It seems that they work for around a day and then can no longer be found. I initialize them in my application.cfm to a value and I can still cfdump them in a regular web page, but the cfc fails with the error Element XXX is undefined in SESSION. Is this normal behaviour? If it is, then what is the alternative method of passing a variable into the cfc (other than making it a parameter when calling)? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360014 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Cannot access session variables in a cfc
What other method than session variables can I use to pass a common variable that won't require me to include it as a parameter of every calling routine? Since you've moved your CFCs out of the application I cannot think of any other method beside passing them all as arguments. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.118 Direct Line: 516-302-4345 www.aimg.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360018 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Cannot access session variables in a cfc
If you moved your cfc's above the application.cfc (or application.cfm) file, the session variables will not be accessible. Session and application vars are accessible from the application file down. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.118 Direct Line: 516-302-4345 www.aimg.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360015 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
If you moved your cfc's above the application.cfc (or application.cfm) file, the session variables will not be accessible. Session and application vars are accessible from the application file down. That's what we did. What other method than session variables can I use to pass a common variable that won't require me to include it as a parameter of every calling routine? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360016 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
You shouldn't, as it breaks encapsulation. Any outside variables you would need inside a cfc should be passed into the cfc, either as part of your object initialization, or directly into a specific method. Cutter On 1/28/2015 10:25 AM, John Pullam wrote: If you moved your cfc's above the application.cfc (or application.cfm) file, the session variables will not be accessible. Session and application vars are accessible from the application file down. That's what we did. What other method than session variables can I use to pass a common variable that won't require me to include it as a parameter of every calling routine? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360017 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
Thanx. That's what I think I will do for the time being. It is hard for me to come up with all the symptoms that we started seeing on the cfc's now and I don't think I could do justice to any explanation of those issues. It seemed to me that it was all quite normal stuff. All pages and cfc's were in the same doc root. And I have had issues with cfc locations on my test system because it gets confused with localhost and virtual directories, so getting the cfc's into a separate folder had a certain appeal. I'm planning to do a big refresh on the app over the summer and this is going to be addressed then. In the meantime, I have my fingers crossed than an application scoped variable will get us through. Thanx again. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360027 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Cannot access session variables in a cfc
You shouldn't, as it breaks encapsulation Honestly, I too think you should reconsider moving the CFC out of the web root. Maybe if you moved them out then created objects from them in the application.cfc, then you may be able to use session vars, as I think the objects would still be in the application. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.118 Direct Line: 516-302-4345 www.aimg.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360020 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Cannot access session variables in a cfc
You will need to pass your session variables as a parameter in order to use them in the CFC, this is best practices anyways. Good news, however, is that you can send them as a complete struct, you don't necessarily need to have them send all separately. cfargument name=sSession type=struct required=yes / Hope this helps, William -- William Seiter -Original Message- From: John Pullam [mailto:jpul...@mcleansystems.com] Sent: Wednesday, January 28, 2015 8:08 AM To: cf-talk Subject: Cannot access session variables in a cfc My app is running in a CF10 system and since I moved my cfc's out of the document root, they are losing access to the session variables. It seems that they work for around a day and then can no longer be found. I initialize them in my application.cfm to a value and I can still cfdump them in a regular web page, but the cfc fails with the error Element XXX is undefined in SESSION. Is this normal behaviour? If it is, then what is the alternative method of passing a variable into the cfc (other than making it a parameter when calling)? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360022 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
I know this isn't ideal, but it is a live application and the decision to move the cfc's outside of the doc root was taken because CF was having trouble finding them (for no obvious reason). Code that has worked since CF7 started breaking. So we moved them and this problem began. I am looking for a quick solution for now, knowing that I need to develop a better one. I'm wondering about putting the variable in the Application scope? Do the cfc's have access to that? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360021 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Cannot access session variables in a cfc
Well, I'd hate to do this, but you could define an application.myvar type variable and put all the variables you need to pass in that as a structure or list, then send that variable in your arguments. That would get to one variable ... but then you're still going to need to deconstruct it before you could use them in the CFC's. Personally I think you should put your CFC's back and fix the problem that's making you move them in the first place. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.118 Direct Line: 516-302-4345 www.aimg.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360026 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
While I agree it isn't a good practice to make use of scope variables in a CFC, try adding an Application.cfc in the root physical directory of your CFCs and use the same application name and session and app timeouts. I think this would work in older versions, but not too sure about more recent versions. On Wed, Jan 28, 2015 at 11:08 AM, John Pullam jpul...@mcleansystems.com wrote: My app is running in a CF10 system and since I moved my cfc's out of the document root, they are losing access to the session variables. It seems that they work for around a day and then can no longer be found. I initialize them in my application.cfm to a value and I can still cfdump them in a regular web page, but the cfc fails with the error Element XXX is undefined in SESSION. Is this normal behaviour? If it is, then what is the alternative method of passing a variable into the cfc (other than making it a parameter when calling)? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360030 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Cannot access session variables in a cfc
try adding an Application.cfc in the root physical directory I don't that that will work. It would still be a separate application pool, and I think you need the CFID and CFTOKEN cookies to have session vars. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.118 Direct Line: 516-302-4345 www.aimg.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360031 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
You could also extend the main application.cfc. You can't do this directly if the cfc's are in a sub-directory though. If that is the case, you could use a proxy, I do this all the time. Here would be the structure. root - Application.cfc - ApplicationProxy.cfc (extends Application) - cfc-folder - - Application.cfc (extends ApplicationProxy) - - myCFC.cfc You will probably want to also call super.onApplicationStart() from within the cfc folder Application.cfc's onApplicationStart() method. The same would hold true for onSessionStart(), you would want to call super.OnSessionStart(). This ensures that all the main application and session vars get initialized properly. On Wed, Jan 28, 2015 at 1:57 PM, Robert Harrison rharri...@aimg.com wrote: try adding an Application.cfc in the root physical directory I don't that that will work. It would still be a separate application pool, and I think you need the CFID and CFTOKEN cookies to have session vars. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.118 Direct Line: 516-302-4345 www.aimg.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360032 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Cannot access session variables in a cfc
John, There are some pretty significant advancements to CFCs since CF 7, especially around scoping. You definitely want to look at the difference up the version chain. Cutter On 1/28/2015 12:02 PM, John Pullam wrote: Thanx. That's what I think I will do for the time being. It is hard for me to come up with all the symptoms that we started seeing on the cfc's now and I don't think I could do justice to any explanation of those issues. It seemed to me that it was all quite normal stuff. All pages and cfc's were in the same doc root. And I have had issues with cfc locations on my test system because it gets confused with localhost and virtual directories, so getting the cfc's into a separate folder had a certain appeal. I'm planning to do a big refresh on the app over the summer and this is going to be addressed then. In the meantime, I have my fingers crossed than an application scoped variable will get us through. Thanx again. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360034 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm