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

  • Home
  • SEARCH
  • 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 969857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:42:42+00:00 2026-05-16T02:42:42+00:00

Hi I have a CFC/component by name tsks_Session, that performs the session tasks. In

  • 0

Hi I have a CFC/component by name “tsks_Session”, that performs the session tasks. In this cfc/ init () function, created a structure that contains all the variables needed in the application.Some of the variables are array types.

<cfcomponent  >
        <cffunction name="init">
        <cfargument name="structKey" >
        <cflock timeout="35" >
         <cfset SESSION = structNew() > 
         <cfset SESSION.bar_code = "" > 
         <cfset SESSION.price = "" >  
         <cfset SESSION.pub_date = "01/01/1900" > 
         <cfset SESSION.author = ArrayNew() >
         <cfset SESSION.title = ArrayNew() >    
         <cfset SESSION.[bar_code_subj_pric] = structNew() > <!--- key = concatanation of    
                                                             bar_code and price --->
         <cfset SESSION.[bar_code_subj_pric].author = ArrayNew() >
         <cfset SESSION.[bar_code_subj_pric].title = ArrayNew() >
        </cflock>
      </cffunction>
     <!---getter--->
     <cffunction name="getAuthor" returntype="array" access="public" output="false"> 
       <cfscript>return SESSION.author;   </cfscript> 
     </cffunction>
     <!---setter:adding the Array/"author"  to the structue/"SESSION.[bar_code_subj_pric]" --->
     <cffunction name="setAuthor" retuntype="void" access="public" output="false"> 
     <cfargument name="bar_code_subj_pric" type="string"  required="true">
     <cfargument name="author" type="array"  required="true">
     <cfset var q = "" >
     <cfparam name="author" default="" >
      <cfloop index="i" from="1" to="arrayLen(SESSION.[bar_code_subj_pric].author)">
       <cfset SESSION.author = ArrayAppend(SESSION.[bar_code_subj_pric].author,"#arguments.author#")>
      </cfloop>
     </cffunction> 

     <!---getter.title--->
     <cffunction name="gettitle" returntype="array" access="public" output="false"> 
       <cfscript>return SESSION.title;   </cfscript> 
     </cffunction>
     <!---setter:adding the Array/"title"  to the structue/"SESSION.[bar_code_subj_pric]" --->
     <cffunction name="settitle" retuntype="void" access="public" output="false"> 
     <cfargument name="bar_code_subj_pric" type="string"  required="true">
     <cfargument name="title" type="array"  required="true">
     <cfset var q = "" >
     <cfparam name="title" default="" >
      <cfloop index="i" from="1" to="arrayLen(SESSION.[bar_code_subj_pric].title)">
       <cfset SESSION.title = ArrayAppend(SESSION.[bar_code_subj_pric].title,"#arguments.title#")>
      </cfloop>
     </cffunction>  
    </cfcomponent>

1) on an display page, having instanitiated the cfc,
i created a str called

<cfset str[expld133] =structnew()>

when i output the functions setAuthor(“expld133”,Kelly)/setTitle(“expld133”,33.22), i get "The value that i am not passing an array type".
Kindly tell me whats wrong?

2) can i create an structure called simply “SESSION” is it safe?

3)is there error in the way i am adding 2 different arrays(Author/Title) to the main structure “SESSION.[bar_code_subj_pric]”?

  • 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-05-16T02:42:43+00:00Added an answer on May 16, 2026 at 2:42 am

    For question #1, I think that the line that is failing is probably one of these two:

    setAuthor("expId133", Kelly);
    setTitle("expId133", 33.22);
    

    Both methods expect an array object as the 2nd argument; but you’re passing a variable named “Kelly” in the first case, and a number in the second case. If “Kelly” is supposed to be the value, not a variable name, you would have to quote it ("Kelly" not Kelly), but that is still not an array. If you want it to be an array containing the 1 string “Kelly” then you would pass ["Kelly"] assuming you’re using CF8 or later.

    For question #2, you can create a variable named “SESSION” (it will go into the component’s VARIABLES scope), and it is “safe”… but I would strongly recommend against it. You’re just asking for confusion. Also, it (the structure) won’t be stored in the session scope (unless the component is stored there). Why not just use the session scope? Why create a new struct called “SESSION”?

    For question #3, I’m not sure if that’s valid syntax or not, but I would guess not. Try either of these:

    SESSION[bar_code_subj_pric] = foo;
    

    This will use bar_code_subj_pric as a variable, and its value will be the structure key name. So if bar_code_subj_pric evaluates to 4, the whole statement evaluates to: session.4 = foo;

    On the other hand, this code:

    SESSION.bar_code_subj_pric = foo;
    //this is also equivalent to:
    //SESSION["bar_code_subj_pric"] = foo;
    

    … creates a key in the SESSION structure named “bar_code_subj_pric” with a value of the foo variable/object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two cfselect boxes that use binds and a cfc. One is State.
I have tried multiple tutorials on this topic from Forta.com and yet run into
This is probably unbelievably basic. In the code below, I have annotated the part
I have an application which uses context sensitive datasources. Currently I keep the datasource
I'm trying to create a button that, when clicked will cycle ad nauseum through
Need to turn javascript (ajax) vote script into reusable (dynamic) script so it can
I've seen all kinds of solutions for extending cfcs in parent folders with access
The following code works fine in FF and Chrome, but not in IE8. I
Trying to pass a form value into a global var to be use in
I'm using the qTip jQuery plugin to generate a dynamic tooltip. I'm getting an

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.