Others may have conflicting opinions... but I don't access the session
scope from within a component.  From the calling template, set the
result into the appropriate scope.

For example... ALL from your .cfm template...

<cfset qAgent = agentLibrary.get_agent(agent_id) />

<cfloop list="#qAgent.columnList#" index="i">
        <cfset session[i] = get[i][1] />
</cfloop>

That way... if another subdomain/site/whatever wants to return the
qAgent into a struct or variables scope (or whatever), you don't have to
touch the CFC.  Keep the application specific code within the
application specific files (model, top of template, whatever).

This is the mindset I live by, but I certainly recognize people should
do what works for them best. HTH

Jason


-----Original Message-----
From: Rick Faircloth [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 18, 2008 9:58 AM
To: CF-Talk
Subject: RE: Would this create session variables?

Thanks for the tip and code, Alan & Barney!
It's working great!

I was concerned that I may end up having to hard-code
the variables and that would greatly reduce the
reusability of the cfc.

Rick

> -----Original Message-----
> From: Barney Boisvert [mailto:[EMAIL PROTECTED]
> Sent: Monday, June 16, 2008 11:57 PM
> To: CF-Talk
> Subject: Re: Would this create session variables?
> 
> try this:
> 
> <cfloop list="#get_agent.columnList#" index="i">
>   <cfset session[i] = get[i][1] />
> </cfloop>
> 
> cheers,
> barneyb
> 
> On Mon, Jun 16, 2008 at 8:44 PM, Rick Faircloth
> <[EMAIL PROTECTED]> wrote:
> > Would this part of a cffunction create
> > individual session variables from the query?
> >
> > <cfquery name="get_agent" datasource="c21ar">
> >     SELECT *
> >       FROM our_agents
> >      WHERE website = '#arguments.website#'
> > </cfquery>
> >
> > <cfset session.get_agent = get_agent />
> >
> > <cfif get_agent.recordCount>
> >
> > <cfreturn session.get_agent/>
> >
> > Back on the invoking page, the returnvariable
> > is 'get_agent'.
> >
> > I've tried to access the specific field data
> > from the cfreturn as session variables, such as:
> >
> > session.agent_header (agent_header is defined by the query)
> >
> > but I'm getting an error that session.agent_header isn't defined.
> >
> > Based on the cfdump data, it looks like the entire query is becoming
> > a session variable (???) rather than getting all the query data
> > defined as individual session variables.
> >
> > I'm trying to get...
> >
> > session.agent_header = '#get_agent.agent_header#'
> > session.first_name = '#get_agent.first_name#'
> >
> > without manually coding all the variables.
> >
> > etc.
> >
> > Thanks,
> >
> > Rick
> >
> >
> >
> >
> >
> 
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307678
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to