sessions and application.cfc

7 views
Skip to first unread message

Jim Priest

unread,
May 8, 2008, 1:25:36 PM5/8/08
to Mach-II for ColdFusion
Trying to get back up to speed on Mach-II. I'm resurrecting my first
(and only) Mach-II app to reuse. To update things I thought I'd try
to use application.cfc.

Now I'm having an issue with session variables. I've got a
'checklogin' plugin that uses session vars - but onSession start
doesn't seem to be getting hit before the plugin is called and I get
an error that my objSession hasn't been defined.

How do I work around this?? I'm off to scour the archives and
hopefully someone has run into this before...

Jim

Jim Priest

unread,
May 8, 2008, 1:38:19 PM5/8/08
to Mach-II for ColdFusion
On May 8, 1:25 pm, Jim Priest <pri...@thecrumb.com> wrote:
> Now I'm having an issue with session variables. I've got a
> 'checklogin' plugin that uses session vars - but onSession start
> doesn't seem to be getting hit before the plugin is called and I get
> an error that my objSession hasn't been defined.

OK - found this quote (from Peter I think)

-------
If you are trying to create session objects at the beginning of the
request. It's best to do that in the onSessionStart() method of your
Application.cfc -- I typically use that to call something like
getProperty("userFacade").onSessionStart() -- this assumes you have
stashed a reference of the userFacade in the mach-ii props and that
you
have created a method in your facade called onSessionStart.
-------

So how would I define this "userFacade" property?

Jim

Peter J. Farrell

unread,
May 8, 2008, 3:10:01 PM5/8/08
to mach-ii-for...@googlegroups.com
To use the on the onSessiopnStart/end plugin points you need to be using Mach-II 1.6 BER. Do not define an onSessionStart method in your App.cfc as it is inherited from Mach.mach-ii. If you have an onSessionStart defined, then you need to call super.onSessionStart() at the end of you method.

Otherwise if you're using 1.5, you create a user facade and stash a reference in the M2 properties. Then use the approach you found on GG.

.Pjf
-----Original Message-----
From: Jim Priest <pri...@thecrumb.com>

Date: Thu, 8 May 2008 10:38:19
To:Mach-II for ColdFusion <mach-ii-for...@googlegroups.com>
Subject: [Mach-II] Re: sessions and application.cfc

Jim Priest

unread,
May 8, 2008, 3:58:23 PM5/8/08
to Mach-II for ColdFusion
OK - I can't move to 1.6 so that's out...

I've kludged it for now and it's working but would like to see an
example of "stash a reference in the M2 properties"??

So I'd have my user or session facade - with a "setupSession" method
or something... How would I put that into a property? Can you
outline some pseudo-code??

Thanks for the help!
Jim

Peter J. Farrell

unread,
May 8, 2008, 11:11:38 PM5/8/08
to mach-ii-for...@googlegroups.com
A few questions:

- Are you using ColdSpring to manage your model?
- Do you have a session / user facade to leverage?

.pjf

Jim Priest said the following on 5/8/2008 2:58 PM:

Jim Priest

unread,
May 9, 2008, 8:04:04 AM5/9/08
to mach-ii-for...@googlegroups.com
No ColdSpring. I do have a 'session facade' setup. Whether it's
'correct' or not - I'm not sure :) My hack yesterday isn't working
so if I can't get this resolved I'm going to have to backtrack and use
Application.cfm until we can move to 1.6...

Thanks!
Jim

Peter J. Farrell

unread,
May 9, 2008, 12:20:59 PM5/9/08
to mach-ii-for...@googlegroups.com
Where are you creating the your SessionFacade.cfc?  If it's at the Mach-II level, you can take a reference to that object and do setProperty("sessionFacade", sessionFacade).  In your onSessionStart() method in your App.cfc, then do <cfset getProperty("sessionFacade").onSessionStart() />.  You'll have to create on onSessionStart() method in your session facade (which would in turn call the other session facade setters that need to be called).

Remember onSessionStart in your Application.cfc is only called when a session begins, so it's a bit difficult to test.  The easiest way to test is dump all your cookies (I like the web developer toolbar for Firefox for this) so the next time you hit a page you get a new session.

.Peter

Jim Priest said the following on 5/9/2008 7:04 AM:

Sean Corfield

unread,
May 11, 2008, 1:36:25 PM5/11/08
to mach-ii-for...@googlegroups.com
On Thu, May 8, 2008 at 12:58 PM, Jim Priest <pri...@thecrumb.com> wrote:
> OK - I can't move to 1.6 so that's out...

Out of curiosity, why not?

I tend to keep all my projects on the BER of all the frameworks as
much as possible because it saves this sort of frustration.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Jim Priest

unread,
May 11, 2008, 4:37:13 PM5/11/08
to mach-ii-for...@googlegroups.com
On Sun, May 11, 2008 at 1:36 PM, Sean Corfield <seanco...@gmail.com> wrote:
> Out of curiosity, why not?
>
> I tend to keep all my projects on the BER of all the frameworks as
> much as possible because it saves this sort of frustration.

I'm a contractor for the Gov't and they move at a snails pace. We are
still on CF7, and moving to anything labeled "beta" is never going to
happen. :)

Jim

Reply all
Reply to author
Forward
0 new messages