Session Variables Not Persisting in Different Folders
Copy link to clipboard
Copied
I have created a login in the root of my site... once a correct login has been confirmed, a session variable is set that forwards the user along to their next location, based on that persons credentials.
The problem I am having is that once the application forwards the user, they land in a different directory and they for some reason have lost the session variable I assigned.
I setup a test page to simply print out my session variables in each directory I go to and I can click forwards and backwards and see the session variable appearing and disappearing.
To make sure that I had no code removing the variable, I created pages that do absolutely nothing but display the vars. Displayed below:
<cfoutput>
#session.county_district#
</cfoutput>
You can view the two pages here:
http://new.fergflor.k12.mo.us/
and here
http://new.fergflor.k12.mo.us/map/
What could be happening that a session loses definitions between folders?
Thanks
Copy link to clipboard
Copied
Are you manually setting the session cookis using either cfcookie or cfheader? If so, are you specifying the PATH attribute for the cookie to somehting other than /?
If you specify a path attribute to /temp, for example, then the cookie would not be sent if you visit a page in the /temp2 folder.
Do your subfolders have sub-applications? DO they have Application.cfc or Application.cfm files?
After visiting the pages above I do not see any obvious problem with the cookies, however the /map page is not working correctly when I visit it. I am getting an IIS 404 and it is trying to redirect me to /map/map.
Jason
Copy link to clipboard
Copied
abatemanffsd wrote:
I have created a login in the root of my site... once a correct login has been confirmed, a session variable is set that forwards the user along to their next location, based on that persons credentials.
The problem I am having is that once the application forwards the user, they land in a different directory and they for some reason have lost the session variable I assigned.
I setup a test page to simply print out my session variables in each directory I go to and I can click forwards and backwards and see the session variable appearing and disappearing.
...
...
What could be happening that a session loses definitions between folders?
I thought immediately of the application file. Here are some suggestions.
1) You should have Application.cfm or Application.cfc in the root directory of your site. If you choose to use Application.cfm, it should have at least the following basic code
<cfapplication
name = "name_of_your_application"
applicationTimeout = "#createTimespan(1,0,0,0)#"
sessionManagement = "true"
sessionTimeout = "#createTimeSpan(0,0,20,0)#"
setClientCookies = "true">
If you choose to use Application.cfc instead, it should contain at least the following code
<cfcomponent>
<cfscript>
this.name = "name_of_your_application";
this.applicationTimeout = "#createTimespan(1,0,0,0)#";
this.sessionManagement = "true";
this.sessionTimeout = "#createTimeSpan(0,0,20,0)#";
this.setClientCookies = "true";
</cfscript>
</cfcomponent>
2) There should be no other instance of these files in a folder above the root unless, of course, you wish it to be the application file for the pages in those folders.
3) Restart ColdFusion (to restart the application).

