swamy
swamy

Reputation: 29

Accessing Session Data in ColdFusion

Here I am trying to access session data in a cold fusion page. you can verify below code Section A code was placed in first page and Section B code was placed in second page. When I am going to second page from first page by printing session data,getting an error.But I can able to access session data in first page itself. Am i missing any required tag in second page to access session data. Can anyone please help me on it.

Section A
<cfapplication name="GetLeadApp"
sessionmanagement="Yes"
sessiontimeout=#CreateTimeSpan(0,0,45,0)#>
<cfset session.uid="#FORM.Username#"/>

Section B
<cfoutput>#session.uid#></cfoutput>

Thanks, Swami

Upvotes: 1

Views: 1186

Answers (1)

Ben Chan
Ben Chan

Reputation: 250

In my limited experience, the filename must be either application.cfc (for universal settings) or application.cfm (for directory-specific settings).

https://helpx.adobe.com/coldfusion/developing-applications/developing-cfml-applications/designing-and-optimizing-a-coldfusion-application/using-an-application-cfm-page.html

So if you're in directory "adir/bdir" and you want to access session variables from directory "adir", you can create a file named "adir/application.cfm" with code from your "Section A", then create another file named "adir/bdir/[name of file].cfm" and put your "Section B". This should enable access to "Section A" session variable from "Section B".

Upvotes: 1

Related Questions