Connecting Tech Pros Worldwide Help | Site Map

ColdFusion Cookie

Newbie
 
Join Date: Feb 2007
Posts: 3
#1: Feb 8 '07
hi all, can anyone help me in understanding the following code:

[HTML]<CFLOOP LIST="ThreadUserEmail,ThreadUserName" INDEX="CurrItem">
<CFIF IsDefined("Cookie.#CurrItem#")>
<CFSET "#CurrItem#" = evaluate("Cookie." & CurrItem)>
<CFELSE>
<CFSET "#CurrItem#" = "">
</CFIF>
</CFLOOP>[/HTML]

is CurrItem an ordinary variable? or its like the session and server variables?
and please explain what does this code does....

Thanks in advance.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Feb 8 '07

re: ColdFusion Cookie


Welcome to The Scripts.

CurrItem is the index of the list. So on the first pass of the list, it will be ThreadUserEmail. The list is specified by list="...".

The code loops through the list which in this case only has two items. It checks if the cookie variables are set (Cookie.ThreadUserEmail and Cookie.ThreadUserName). If any are set, it creates a new variable called ThreadUserEmail or ThreadUserName and sets it to the current cookie value. If its not set, it sets it to empty.

If you need any more help, feel free to post again.
Reply