House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Session variables not working

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
02/27/2012 03:15 PM

It's been awhile since I used session variables, but this is simple.  Why won't this work? session-test.cfm ---------------- <cfset session.name = 'rick'> <cfoutput>#session.name#</cfoutput> <cflocation url="session-test-2.cfm"> session-test-2.cfm ------------------ <cfoutput>#session.name#</cfoutput> I get the error 'Element NAME is undefined in SESSION.' ??? Session variables are specified for use in CFADMIN. Am I missing something REALLY simple or obvious? Rick

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve Milburn
02/27/2012 03:18 PM

Have you enabled session management in the application.cfc? On Mon, Feb 27, 2012 at 3:14 PM, Rick Faircloth <Rick@whitestonemedia.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
02/27/2012 03:29 PM

There's no application.cfc at this point...the only two pages involved are what's in this email. Is enabling session management in an application.cfc necessary for session management to work? As you can see below when I use: <cfset session.name = 'rick'> and then output that with: <cfoutput>#session.name#</cfoutput> I get 'rick'... But that's on the same page. Would that work but not session variables between pages with session management being enabled in application.cfc? Rick Have you enabled session management in the application.cfc? On Mon, Feb 27, 2012 at 3:14 PM, Rick Faircloth <Rick@whitestonemedia.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Russ Michaels
02/27/2012 03:36 PM

yes you must have an application.cfm/cfc in order to enable session variables. On Mon, Feb 27, 2012 at 8:28 PM, Rick Faircloth <Rick@whitestonemedia.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
James Holmes
02/27/2012 10:56 PM

Actually, a cfapplication tag will work fine outside of Application.cfm so technically this isn't true. Of course it makes sense to use Application.cfm or Application.cfc. -- Shu Ha Ri: Agile and .NET blog http://www.bifrost.com.au/ On 28 February 2012 04:36, Russ Michaels <russ@michaels.me.uk> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
02/28/2012 07:41 AM

I normally use an application.cfc, but this was just a quick "proof-of-concept" that I threw together to test something. Actually, a cfapplication tag will work fine outside of Application.cfm so technically this isn't true. Of course it makes sense to use Application.cfm or Application.cfc. -- Shu Ha Ri: Agile and .NET blog http://www.bifrost.com.au/ On 28 February 2012 04:36, Russ Michaels <russ@michaels.me.uk> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
02/27/2012 03:36 PM

Well, after quickly throwing together an application.cfc, I can see that it is necessary.  It attached the CFID and CFTOKEN to the URL. There's no application.cfc at this point...the only two pages involved are what's in this email. Is enabling session management in an application.cfc necessary for session management to work? As you can see below when I use: <cfset session.name = 'rick'> and then output that with: <cfoutput>#session.name#</cfoutput> I get 'rick'... But that's on the same page. Would that work but not session variables between pages with session management being enabled in application.cfc? Rick Have you enabled session management in the application.cfc? On Mon, Feb 27, 2012 at 3:14 PM, Rick Faircloth <Rick@whitestonemedia.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Azadi Saryev
02/27/2012 09:20 PM

In your <cflocation> tag include addtoken="no" attribute to prevent CFID/CFTOKEN vars from being appended to the url. I'll also suggest you set your server to use J2EE sessions in CF Administrator, if you have not done so already. Azadi ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
02/28/2012 07:40 AM

Thanks for that reminder... it's been years since I've even used cflocation! My how knowledge, unused, is fleeting... In your <cflocation> tag include addtoken="no" attribute to prevent CFID/CFTOKEN vars from being appended to the url. I'll also suggest you set your server to use J2EE sessions in CF Administrator, if you have not done so already. Azadi ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve Milburn
02/27/2012 03:39 PM

You will need an application.cfc (or .cfm) for session variables to work. In your example, your <cfset session.name = 'rick'> was actually stored in the variables scope on that page as variables.session.rick, and not actually in the session scope.  That is why it was not available on the other page. On Mon, Feb 27, 2012 at 3:28 PM, Rick Faircloth <Rick@whitestonemedia.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve Milburn
02/27/2012 03:41 PM

Correction on my previous post: The variable was stored in variables.session.name (not variables.session.rick)...  but you probably knew what I meant.. ;-) ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
02/27/2012 04:02 PM

Thanks for the reminder! Rick Correction on my previous post: The variable was stored in variables.session.name (not variables.session.rick)...  but you probably knew what I meant.. ;-) ----- Excess quoted text cut - see Original Post for more ----- <Rick@whitestonemedia.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jay Pandya
02/28/2012 12:49 AM

Hi Rick,         When you are using session variables and you want to get its value in other page after using cflocation then you need to enable seclientcookies true in cfapplication tag. More description you can read on http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_a-b_5.html read Setclientcokies description. Thank You Jay Pandya ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
02/28/2012 07:42 AM

Thanks, Jay! Rick Hi Rick,         When you are using session variables and you want to get its value in other page after using cflocation then you need to enable seclientcookies true in cfapplication tag. More description you can read on http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_a-b_5 .html read Setclientcokies description. Thank You Jay Pandya ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

June 20, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
             1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30             

Designer, Developer and mobile workflow conference