Jump to content
xisto Community
Sign in to follow this  


Recommended Posts

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

if( var1 == var2 ){// What Happens Here}

Now in ColdFusion.

<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

CF ----What it Does------ PHPeq ------ 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.

$var = "what ever it is";// Where $var is the variable.

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

<cfset var1 = "whatever">

Now calling out CF statments variables is not so diffrent than from PHP for this reasonIn 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...

<?php// your codeecho "$var1";// you code?>

Now doing this in Coldfusion looks like this...


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


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

<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 endit now than to get hurt in the long run.So Lets Review some of what we know.

<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 this23988kald8923920112 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

<cfoutput> #createUUID()# </cfoutput>Just think of the above like this Create Unique User Id --- thats what it stands for 

The code aboves allow you to see what the session number and how it looksNow 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....

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

Now to call on the cookie....


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 doesget the value... if it doesnt set a new value...So here is what it is doing... even thou you set a cookie.....FIRST ACCESSPAGE ACCESS --- GIVE UUID --- SET COOKIE TO UUIDPAGE REFRESHREFRESH --- GIVE UUID -- UPDATE UUIDHow to fix this is like so APPLING WHAT YOU KNOW!!!!!!!!!! Yippie Skippie....

<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 validatethe TOKEN by a couple means that i'm not going to get into untill later...TO BE CONTIUNED...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.