Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8077071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:24:00+00:00 2026-06-05T15:24:00+00:00

I have a Coldfusion8 page, in which I’m declaring some variables upfront like so:

  • 0

I have a Coldfusion8 page, in which I’m declaring some variables upfront like so:

<cfif (structKeyExists(url,"extern"))>
    <cfset variables.someVar = "value">
<cfelse>
    <cfset variables.someVar = "">
</cfif>

Following this I have a number of templates, which I’m loading:

<cfinclude template="templates/tmp_pagetop.cfm">
<cfoutput><head></cfoutput>
<cfinclude template="templates/tmp_pageheader.cfm">
... 

I’m having trouble accessing my variables.someVar inside my template.

Question:
Is this at all possible using the variables scope? I don’t want to use session or application scope, because the variables I’m dealing with should actually only exist in the respective page. But I thought it would be possible to declare once in the page and reference throughout the templates. If I can’t use variables, is there another way?

EDIT:
First up, thanks for all the feedback!

When I started using SO, I usually put up questions like below, but ended up cutting down to the bare minimum, as I usually didn’t get an answer on thourough questions… pity… I guess I may be leaving too much away 🙂

So, if anyone wants to take a look, I have a page called search.cfm. This page is a shell page into which I’m loading different layouts through AJAX and/or templates. Specific case was the search form loaded via AJAX.

So this is 3 parts:

1) search.cfm Here I’m checking Session.extern(al) for local instances of the page. If it’s a local instance I grab the users variabels A,B,C which I had hoped to access when loading in the search form template.

<cfif (structKeyExists(url,"extern"))>
    <!--- preload external user data  --->
    <cfstoredproc procedure="proc_select_extern" datasource="dtb">
        <cfprocparam type="in" value="#Session.extern#" cfsqltype="cf_sql_varchar" maxlength="13">
        <cfprocresult name="external_user">
    </cfstoredproc>

    <!--- set external variables --->
    <cfif external_user.recordcount eq 1>
        <cfoutput query="external_user">
            <cfscript>
            // CULPRIT string
            variables.user_modules = external_user.modules;
            </cfscript>
        </cfoutput>
    <cfelse>
    <!--- remove unknown URL params --->
        <cfset StructDelete(Session, "Extern")>
    </cfif> 
</cfif>

Then in my app.js I’m listening for the (Jquery-Mobile) pagebeforeshow event and load the respective form into the page via AJAX:

$(document).on('pagebeforeshow', '#search' , function(e, data) {
    // load main search form
    if ( $(this).attr('val') != true ) {
        $(this).attr('val') == true;
        // here I'm calling the default search form
        ajaxUpdate( "../layouts/tmp_searcher.cfm", $('.searchFromWrapper'), "search", "default", "search" );
        }
....
var ajaxUpdate = 
    function update( from, target, param, account, bindings ) {
        $.mobile.loading( 'show' );
        $.ajax({
            async: true, type: 'GET', returnFormat: 'json', 
            data: { value: param, type:  account },
            url: from, timeout: 7500,
            success: function(data) {
                var makeUp = !$.support.touch ? data.replace("<select", "<select data-native-menu='false' ") : data;
                target.addClass('.fade.out')
                    .html( makeUp ) 
                        ...
                });

The tmp_searcher.cfm template being loaded contains all search form variants. On initial load I’m grabbing the basic or external(userID) based one.

It’s inside tmp_searcher.cfm, where I cannot access variables.XXX anymore… same as URL from my earlier question…. Oh well, writing it down it sort of makes sense, why it’s not working 😉

I spare you the details, first line in tmp_searcher.cfm is:

<cfdump output="D:\ColdFusion8\logs\dump.txt" label="catch" var="#variables.user_module#">

Which dumps nothing and (@Leigh) throws an error:

Element USER_MODULE is undefined in VARIABLES

So, my question should have been:

Is there a way for Coldfusion variables to persist through AJAX calls, if the content is on the same page and I’m not wanting to use Session or Application Scope?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:24:01+00:00Added an answer on June 5, 2026 at 3:24 pm

    You can use the request scope. That will let you access any variables in the request, including the templates.

    But the way I use to do it was to use cfimport with a prefix like.. “ui”

    <cfimport taglib="templates" prefix="ui">
    <ui:tmp_pagetop heyLookAVar="#myvar# >
    

    Then inside your template you have access to attributes.heyLookAVar

    You can get really fancy and detect if the template calling tag is ending or beginning… then you only need one

    <ui:page>
       my page
    </ui:page>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy .cfm (ColdFusion) page which used to process form data (from
We have a ColdFusion page where admins can insert/update some real estate records after
I have a ColdFusion script that does: <cfset content = replace(content,&##147;,,all)> Which replaces &147;
I'm confused as to how to accomplish this. I have a page which, has
I have a drop box which is populated by information from a database. Some
I have a web page which links to an Excel 2007 worksheet. It is
I have a web page in ColdFusion which shows contents from a SQL table.
I have a URL, and I want to get the final page name out
I have a URL that goes to a pdf file. In my coldfusion page,
I have a SQL database with a ntext field which holds page content. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.