Hello,

I havent really seen to many coldfusion tutorials around. I also looked for some on here which I couldnt find any... (Must have over looked if I did'nt see it).

Anyways we are going to be learning the basics of ColdFusion and from now on I may refer to it as CF so please do not get confused.

CF is a very powerfull scripting language, it is a easy transistion if you know PHP, and is also easy to learn if you do not.

In CF you have diffrent operators styles and IF formats.


Example:

PHP Operators in a IF statement
CODE


if( var1 == var2 ){

// What Happens Here

}



Now in ColdFusion.
CODE


<cfif var1 eq var2>
<!-- Whatever happens Here //-->
</cfif>



The operator (eq) is the same as (==) meaning EQUALS.
ColdFusion in a sense is kinda more logical than PHP, although some may beg to differ.

Most of the ColdFusion operators compared to PHP

CODE


CF ----What it Does------ PHP

eq ------ Equals -------------------------- ==
lt -------- Less than -------------------------- <
gt ------- greater than ----------------------- >
gte ------ greater than or equal too -------- >=
lte ------- less than or equal too ----------- <=



Those abover are just the common ones.

Setting Variables in ColdFusion.

I'm not really going to go over how to see up Variables in PHP but in case you dont know its.

CODE


$var = "what ever it is";

// Where $var is the variable.



Now, setting a variable in ColdFusion looks like this...

CODE


<cfset var1 = "whatever">



Now calling out CF statments variables is not so diffrent than from PHP for this reason

In PHP you cannot call out a variable unless you have it in the area of the program that is going to be complied
by the php interpeter.

Example...


CODE


<?php

// your code

echo "$var1";

// you code

?>



Now doing this in Coldfusion looks like this...

CODE


<cfoutput>

#var1#

</cfoutput>



Just rember that (var1) is the variable that you set, it will be whatever you named it...
Also notice the

CODE
#'s


Around the variable... This is what I call the RUN FUNCTIONS although its not really called that.
I like to keep things simple... Just remember KISS = Keep It Simple Stupid... You will go far.

Ok... Now more to expalin the

CODE
<cfoutput> and the </cfoutput>


The CFOUTPUT is basicly the <?php in php... although in coldfusion you
do not need the cfoutput to set a variable.

and the </cfoutput> is the ?> in php... Remember this.. all good things must come to an end so its best to end
it now than to get hurt in the long run.

So Lets Review some of what we know.

CODE


<cfset var1 = "whatever"> <!-- Sets a variable //-->

<cfoutput> allows us to call on our variables.




OK! We are doing good... now in php there is a thing called a SESSION which gives you some gobally guke that looks like this
23988kald8923920112 or whatever....

and COLDFUSION makes it look more professional with less risk of the possible SESSION HIJACKING! (WHICH WE WANT GET INTO YET)

So....

How do I set a CF session?

Well... It's simple...

As soon as you logon to a coldfusion server you are giving one of these session numbers,

However, it updates per page you are going because you have not yet set that session on there machine.

(if that confuses you like it does me, just know how to set it on the machine and get it OVER WITH!!!!)

How to Display the SESSION NUMBER

CODE


<cfoutput>

#createUUID()#

</cfoutput>

Just think of the above like this Create Unique User Id --- thats what it stands for smile.gif



The code aboves allow you to see what the session number and how it looks

Now how do I set a session on there computer?

Well, it deals with cookies....

How do I set a cookie?

Setting a cookies is very idiot proof when it comes to coldfusion....

CODE


<cfcookie name="namethecookie" value="#createUUID()#">



Now to call on the cookie....

CODE


<cfoutput>#namethecookie#</cfoutput>



Now ok... its set but it still gives me a diffrent number every time... WHY?

Well thats because you need to check to see if that cookie exsist... and if it does
get the value... if it doesnt set a new value...

So here is what it is doing... even thou you set a cookie.....

FIRST ACCESS

PAGE ACCESS --- GIVE UUID --- SET COOKIE TO UUID

PAGE REFRESH

REFRESH --- GIVE UUID -- UPDATE UUID


How to fix this is like so APPLING WHAT YOU KNOW!!!!!!!!!! Yippie Skippie....

CODE


<cfif #thecookienameyouset# lt "">
<cfcookie name="thecookienameyouset" value="#createUUID()#">
<cfset token = "#thecookienameyouset#">
<cfelseif>
<cfset token = "#thecookienameyouset#">
</cfif>

Now to call upon it

<cfoutput> #token# </cfoutput>



The above is just the quickest was to check to see if the cookie exsit... however you can slow check to validate
the TOKEN by a couple means that i'm not going to get into untill later...


TO BE CONTIUNED...

 

 

 


Reply