Solved

helpt o explan cookie syntax

Posted on 2004-10-07
4
183 Views
Last Modified: 2013-12-24
Can someone help me to under these 2 lines of syntax.

<cfset "client.cfid#client.CFID#.cftoken#client.CFToken#.username" = "">
<cfset "client.cfid#client.CFID#.cftoken#client.CFToken#.password" = "">

why the # sign?
0
Comment
Question by:xiaobao68
4 Comments
 
LVL 5

Accepted Solution

by:
kkhipple earned 25 total points
ID: 12248973
CFCOOKIE livedocs
http://livedocs.macromedia.com/coldfusion/6/CFML_Reference/Tags-pt119.htm

<cfset "client.cfid#client.CFID#.cftoken#client.CFToken#.username" = "">
<cfset "client.cfid#client.CFID#.cftoken#client.CFToken#.password" = "">


The #'s signs are used to grab the variable values.  
If you place <CFOUTPUT></CFOUTPUT> tags around the variable, then you can view the value.

<CFOUTPUT>
#client.CFID#
</CFOUTPUT>  

If you want to view the value of the above two set statements :

<CFOUTPUT>client.cfid#client.CFID#.cftoken#client.CFToken#.username</CFOUTPUT>

Actually its an interesting bit of code. It defines a unique username and password variable.

Possible for authentication/authorization.
0
 
LVL 35

Assisted Solution

by:mrichmon
mrichmon earned 25 total points
ID: 12250463
The reason that the # is needed is becuase it is within double quotes.

You could get the same result with the following code:

<cfset Client["cfid" & client.CFID & ".cftoken" & client.CFTOKEN & ".username" = "">
<cfset Client["cfid" & client.CFID & ".cftoken" & client.CFTOKEN & ".password" = "">

It is NOT setting a cookie.  It is setting a client variable.

So if client.CFID = 12 and Client.CFTOKEN = 1T67YA85 then you actually have the statements

<cfset Client.cfid12.cftoken1T67YA85.username = "">
<cfset Client.cfid12.cftoken1T67YA85.password= "">

Personally I am not sure why you would go to this trouble of such a complex variable name for a user's username and password.  There are much simpler ways to make usique username and password variables without having so many layers deep.  And it would be very messy to use later in your pages....
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question