• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

session vars, CFCs and CFHTTP

New Here ,
Apr 29, 2008 Apr 29, 2008

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

658

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 29, 2008 Apr 29, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2008 Apr 29, 2008

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 29, 2008 Apr 29, 2008

Copy link to clipboard

Copied

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

Posting the relevant bits of your code and telling us exactly what's going
on, and how you've tried to troubleshoot it would be a good start.

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 29, 2008 Apr 29, 2008

Copy link to clipboard

Copied

My method is to not use session variables inside cfc's. Anything the functions need are passed as arguments.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 01, 2008 May 01, 2008

Copy link to clipboard

Copied

LATEST
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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation