Since both session and form are structures, you can use array-style syntax:

<cfloop index="field" list="#form.fieldnames#">
  <cfset session[field] = form[field]>
</cfloop>

The <cfoutput> tags are unnecessary.  And remember to use <cflock> around
the whole thing...

> -----Original Message-----
> From: Jay Wigginton [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 16, 2001 4:35 PM
> To: CF-Talk
> Subject: form to session
>
>
> Is there a simple way to take the values submitted from a form and setting
> session variables with the same name... example:
>
> form submits variables.... Form.FirstName and Form.LastName... I need to
> set... Session.FirstName = Form.FirstName and Session.LastName =
> Form.LastName...
>
> I know I can use... <cfset Session.FirstName = Form.FirstName>
>
> But, I want to do this <cfloop> looping over the fieldnames... something
> like...
>
> <cfloop index="field" list="#fieldnames#">
>       <cfoutput>
>               <cfset session.#field# = Form.#field#>
>       </cfoutput>
> </cfloop>
>
> The above produces an error... :(
>
>
> thanks in advance
> Jay
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to