session variables expire between pages?

I'm moving a client site to jodohost. The backend uses sessions to track logins etc. and works fine with cookie-stored sessions on the existing host's shared CF servers.

When I test the new site on jodohost's servers, however, my sessions do *not* persist -- they die without a trace unless I set my <cflocations> to addtoken and wrap my a href locations with urlencodedformat().

There's got to be something fundamentally wrong that I'm just not picking up on here, but I've tried every variation on session and client storage that I can think of with no luck.

A real quick demo of the problem can be found here: http://204.10.107.95/admin/test.cfm. Sets a session variable, proves it's been set -- but if you then click a link to some other page on the same site, the session variable has vanished.

Anyone tell me what I'm missing here?
 
It is best to store the session as a cookie so it does not need registry access.
 
stephen,

thx -- i thought that was what it was doing by associating the session with a cftoken that's stored as a system-only cookie?

Are you suggesting bypassing session scope alltogether and simply setting a cookie that holds the necessary info? Doesn't that create problems when visitors close their browser w/o properly ending the session and allowing the system to delete the cookie as required?
 
thingwarbler said:
A real quick demo of the problem can be found here: http://204.10.107.95/admin/test.cfm. Sets a session variable, proves it's been set -- but if you then click a link to some other page on the same site, the session variable has vanished.

Anyone tell me what I'm missing here?
Would you mind posting to code for those two test pages? Also, which CF server is your app running on?

You also mentioned that this code runs fine on your other host, what version of CF are they running there?
 
Hatton, thx for following up on this.

Here's the code from test.cfm:

<cfapplication name="neaetc" clientmanagement="yes" sessionmanagement="yes" setclientcookies="yes" setdomaincookies="yes" sessiontimeout="#createtimespan(0,4,0,0)#" clientstorage="cookie">
<!--- Set a session variable called session.test --->
<cflock scope="session" throwontimeout="no" type="exclusive" timeout="5">
<cfset session.test = "neaetc">
</cflock>
<!--- output session var --->
<p>Dump session.test. The variable is currently: <cfoutput>#session.test#</cfoutput></p>
<p>Okay, now <a href="test2.cfm">go here</a>, a simple a href link within the same site, same folder etc., and see if the session survives?</p>

And here's test2.cfm

<p>Same application, same domain <br />
-- but now what happened to session.test that we just set a single link ago?</p>
<p><cfoutput>#session.test#</cfoutput></p>

The error I get is: Element TEST is undefined in SESSION, but on test.cfm (the first page, where session.test is first set) the variable is parsed out just fine, so it exists right up until the new page is loaded.

Your thoughts?
 
hatton,

one last follow-up: client variables persist across pages with the setup I'm testing. That makes sense, since client vars are explicitly forced into cookies as specified in the cfapplication tag, but shouldn't those same cookies be used by CF to maintain sessions?

The site currently sits on a CF5 Windows server. I'm trying to move this to wincf.jodoshared.com.
 
<cfapplication name="neaetc" clientmanagement="yes" sessionmanagement="yes" setclientcookies="yes" setdomaincookies="yes" sessiontimeout="#createtimespan(0,4,0,0)#" clientstorage="cookie">
<!--- Set a session variable called session.test --->
<cflock scope="session" throwontimeout="no" type="exclusive" timeout="5">
<cfset session.test = "neaetc">
</cflock>
<!--- output session var --->
<p>Dump session.test. The variable is currently: <cfoutput>#session.test#</cfoutput></p>
<p>Okay, now <a href="test2.cfm">go here</a>, a simple a href link within the same site, same folder etc., and see if the session survives?</p>

And here's test2.cfm

<p>Same application, same domain <br />
-- but now what happened to session.test that we just set a single link ago?</p>
<p><cfoutput>#session.test#</cfoutput></p>

Your thoughts?
You need the CFApplication tag on test2.cfm
 
hatton,

sorry, should have made that clear: there's an underlying application.cfm that'll run for both these pages -- I only included the cfapplication in test.cfm for clarity.
 
Just as a quick try, take the CFLock out around the set in the first page. Shouldn't make a difference but it's worth a shot.
 
Heh, I actually did it the other way around -- intially there was no cflock (that didn't work) -- then I thought I'd give it a try with the lock in place (still didn't work). But thx for suggesting it.

For now I'm probably going to rebuild the whole thing with either straight client variables cookies or addtoken and urlencodedformat. Bummer.
 
Back
Top