Skip to main content
Participating Frequently
April 29, 2008
Question

session vars, CFCs and CFHTTP

  • April 29, 2008
  • 3 replies
  • 716 views
Hi guys

I'm using session vars to maintain whether or not a user is logged in on our site. The only problem is is that the session vars seem to be lost after I call a CFC that then does a CFHTTP post.

Does anyone know how I maintain the session vars?

I'm using CF MX 7

All the best

Wez
This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
May 1, 2008
Wez wrote:
Does anyone know how I maintain the session vars?

Yes. Do the following:

1) Navigate to Server Settings => Memory Variables in the Coldfusion Administrator. Enable the use of application variables as well as session variables.

2) Your Application.cfc file should at least contain a setup like this
<cfscript>
this.name = "yourAppName";
this.applicationTimeout = "#createTimeSpan(1,0,0,0)#";
this.sessionManagement = "yes";
this.sessionTimeout = "#createTimeSpan(0,0,20,0)#";
</cfscript>

Inspiring
April 29, 2008
My method is to not use session variables inside cfc's. Anything the functions need are passed as arguments.
Inspiring
April 29, 2008
wezcornell2008 wrote:
> Hi guys
>
> I'm using session vars to maintain whether or not a user is logged in on our
> site. The only problem is is that the session vars seem to be lost after I call
> a CFC that then does a CFHTTP post.
>
> Does anyone know how I maintain the session vars?
>
> All the best
>
> Wez
>


Why do you say they are lost? Are you sure you did not just misplace them?

In other words nothing about CFC's or CFHTTP would intrinsically destroy
session variables in memory. But they could easily not have access to
the scope as you desire if you do not understand how templates and cfml
code are associated with a given session scope when it is running in memory.

Participating Frequently
April 29, 2008
Thanks for the reply.

Thank you for clarifying that the session vars are not 'lost'. I was hoping that would be the case.

Please could you expand on how I would regain access to them through the correct scope.

Many thanks in advance.

Wez