0

I'm a new comer to ColdFusion and am trying to convert CF web app to ASP.NET web app. We've Index.cfm file and a template Manage.cfm file. If a user clicks on a link in Index.cfm it opens a URL with something like http://localhost/index.cfm?t=Manage.cfm. The template Manage.cfm is using a message <p>Year of Completion is : <cfoutput>#session.YearOfCompletion#</cfoutput>

But neither in Index.cfm nor in Manage.cfm I see a place where session.YearOfCompletion or form.YearOfCompletion value is set. Question: How then template is getting #session.YearOfCompletion# value in the output? It seems I'm missing something.
nam
  • 21,967
  • 37
  • 158
  • 332
  • Somewhere it is being set. Look in the Application.cfc if there is one. What is the structure of your files. What other files do you have besides index.cfm and Manage.cfm in your folders. There might be an init function somewhere declaring session variables. – Leeish Aug 12 '16 at 20:28
  • Search the code base for `cfset session.YearOfCompletion`. – Adrian J. Moreno Aug 12 '16 at 20:49
  • @Leeish Thank you for pointing out Application.cfm. This file has a `cfquery` tag that fetches the YearOfCompletion value from database and then set Session.YearOfCompletion to that value. Do you want to convert your suggestion into a Response explaining briefly what the cause could be. And, I'll mark it as an answer - this will help other readers of this post. – nam Aug 12 '16 at 21:05
  • Sure. I'll write something a bit more complete as to how I made the guess. – Leeish Aug 12 '16 at 21:05
  • @AdrianJ.Moreno Thank you for trying to help. Searching for the value in Application.cfm, as suggested by Leeish, resolved the issue. – nam Aug 12 '16 at 21:09

1 Answers1

4

It's common for developers to init a ColdFusion application and a common place to start looking is in the application.cfc(.cfm) file in the application folder. Developers may do things differently, but for session variables especially, there is a default function called onSessionStart which fires once for each new user session.

Most likely it is in that function default values are being set for the session variables. Other locations may be from componenets created and initiated from within the onRequest onRequestStart or onSessionStart functions.

Leeish
  • 5,203
  • 2
  • 17
  • 45
  • Thank you for sharing the details. As one of your guesses, the value was set in Application.cfm. Being a new comer to CF, I ignored that. – nam Aug 12 '16 at 22:18