> "session.#attributes.CartName#" = StructNew();
> "session.#attributes.CartName#.items = ArrayNew();
>
> Which seems to work fine, however if I try the following line:
>
> "session.#attributes.CartName#.items[1] = "blahblahblah";
> or
> <cfset "session.#attributes.CartName#.items[1]" = "blahblahblah">
>
> I get the following error:
>
> ---
> Cannot set dynamic variable with name 'session.myCart.items[1]'. The
variable name is illegal. Variable names
> must start with a letter and can include only letters, numbers, and
underscores.

It would be better to treat the session structure as an associative array...

session[attributes.cartName] = StructNew();
session[attributes.cartName].items = ArrayNew(1);  // Note you missed the 1
in this...

session[attributes.cartName].items[1] = "blahblahblah";

that way you get away from that whole hacky way of setting dynamic
variables.  You could also use setVariable - but I think this way is cleaner
personally.

---
James Sleeman

______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to