1

Is it possible to set a session variable and then to change it later if it equals a certain value?

<cfif session.checkout.vehicle.vehiclebody eq "TK1" or "TK2" or "TK3" or "TK4" or "TK5"> <cfparam name="#session.checkout.vehicle.vehiclebody#" default="TK"> </cfif> 

What I am trying to do is if the session variable equals TK1,TK2,TK3,TK4, or TK5 then to reassign the session variable to equal just TK

So that then #session.checkout.vehicle.vehiclebody# is eq to "TK"

Any help with this would be greatly appreciated!

2
  • 1
    Scott has given you the answer, but it's important that when you have issues, you read the docs! cfparam: wikidocs.adobe.com/wiki/display/coldfusionen/cfparam & more importantly wikidocs.adobe.com/wiki/display/coldfusionen/… (the entire section). Can I also recommend that if you're just starting out, try to avoid coding using tags, which really ought to be reserved for views, not general processing code. Commented Apr 6, 2015 at 23:04
  • He is referring to the fact that CF can be written using script syntax rather than tags and is largely the preferred choice in modern CF apps, especially in CFC's. Using this syntax helps make the transition between CF and other languages like C# and JavaScript a bit easier. Commented Apr 6, 2015 at 23:58

1 Answer 1

2

Try this:

<cfparam name="session.checkout.vehicle.vehicleBody" default="TK" /> <cfif listFindNoCase("TK1,TK2,TK3,TK4,TK5", session.checkout.vehicle.vehicleBody)> <cfset session.checkout.vehicle.vehicleBody = "TK" /> </cfif> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.