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

Session variable being lost between parent and include file

Contributor ,
Dec 14, 2011 Dec 14, 2011

Copy link to clipboard

Copied

I am running into the following scenario: Page 1 includes page 2, on both pages a session variable is returned to the screen. On occasions, page 2 throws an error on the session variable even though it was successfully called on page 1.

It only happens occassionally, and is very difficult to recreate in order to debug it in realtime. Has anyone run into something like this before? Thanks!

Views

1.0K

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 ,
Dec 14, 2011 Dec 14, 2011

Copy link to clipboard

Copied

Same general idea but different details.  It happens when the user is running the same application in different browser windows or tabs.  It's all the same session so on occasion activity in Window B overwrites session variables written in Window A.

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
Participant ,
Dec 14, 2011 Dec 14, 2011

Copy link to clipboard

Copied

Sounds like you need to use cflock to prevent multiple requests from accessing those variables at the same time.

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 ,
Dec 15, 2011 Dec 15, 2011

Copy link to clipboard

Copied

semi star gazer wrote:

I am running into the following scenario: Page 1 includes page 2, on both pages a session variable is returned to the screen. On occasions, page 2 throws an error on the session variable even though it was successfully called on page 1.

It only happens occassionally, and is very difficult to recreate in order to debug it in realtime. Has anyone run into something like this before? Thanks!

I suspect it has less to do with page-inclusion, more to do with the code on page 2. Suppose, instead of using cfinclude, you had copied the code from page 2 into page 1, and made 1 page of it. Then the error would still have occurred. That's at least my theory.

Have a look at how the code in page 2 handles the session. There is bound to be something not quite right about it. What kind of error do you get anyway?

Runtime debugging can be as simple as this:

<cftry>

<cfinclude template="page2.cfm">

<cfcatch type="any">

<cfdump var="#cfcatch#"><cfabort>

</cfcatch>

<cftry>

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 ,
Dec 15, 2011 Dec 15, 2011

Copy link to clipboard

Copied

LATEST

Regarding:

I suspect it has less to do with page-inclusion, more to do with the code on page 2

I share that suspicion.  The scenario in the OP is different than what I described earlier.  Given that the problem appears to be intermittent, I suspect that something is happening to the variable, inside some conditional logic code.

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