Session variable in setupSession

213 views
Skip to first unread message

Eapen

unread,
Jul 20, 2010, 12:52:10 PM7/20/10
to framework-one
I need to change the way Session variables are handled in a live
application.

I need the session variables to expire when the browser is closed and
was following Ben's example here:
http://www.bennadel.com/blog/1131-Ask-Ben-Ending-ColdFusion-Session-When-User-Closes-Browser.htm

I added
this.setClientCookies = false;
to the Application.cfc and when I try to add a
<cfcookie name="CFID" value="#SESSION.cfid#" />
in the "setupSession", I get the error "Element CFID is undefined in
SESSION".

How do I set this cookie right after the Session has been created or
are there any other better methods/suggestions?

Thanks!

Fernandez, Miguel

unread,
Jul 20, 2010, 1:45:37 PM7/20/10
to framew...@googlegroups.com
Did you also enable session management in your application.cfc?

this.SessionManagement = true

Another thing to check is if your coldfusion server is configured to use J2EE cookies. If so, then I don't think coldfusion uses cfid/cftoken any more. It uses something like a uuid instead.

Just a couple things off the top of my head.

- Miguel

Thanks!

--
FW/1 on RIAForge: http://fw1.riaforge.org/

FW/1 on github: http://github.com/seancorfield/fw1

FW/1 on Google Groups: http://groups.google.com/group/framework-one

Eapen

unread,
Jul 20, 2010, 1:59:51 PM7/20/10
to framew...@googlegroups.com
Thanks Miguel. I am using this.SessionManagement = true and it is not configured to use J2EE cookies.

Dave Anderson

unread,
Jul 20, 2010, 4:03:45 PM7/20/10
to framework-one
Seems like the question is not so much how to set the cookie value,
but rather how to expire the session when the window is closed, which
is your end goal, right? To the best of my knowledge, there's no good
way to do that. You could use the window onUnload event, but that
fires when you refresh a page, so that's no good.

As for the cookie issue -- turn on output debugging (if it's not on)
and take a look at what's defined in your session scope. There should
be a URLTOKEN key, and you can set a cookie to that value (before or
after manipulating it, because it likely contains
cfid=xxxx&cftoken=xxxxxxxxx). If the cookie's not being set by
setupSession because the sessionID hasn't been set when the cookie
attempt is made, you may need to override setupSession() and add it at
the end.

Dave

On Jul 20, 11:52 am, Eapen <gea...@gmail.com> wrote:
> I need to change the way Session variables are handled in a live
> application.
>
> I need the session variables to expire when the browser is closed and
> was following Ben's example here:http://www.bennadel.com/blog/1131-Ask-Ben-Ending-ColdFusion-Session-W...
Reply all
Reply to author
Forward
0 new messages