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...
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.
-------
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.
-----Original Message-----
From: Jim Priest <pri...@thecrumb.com>
Date: Thu, 8 May 2008 10:38:19 To:Mach-II for ColdFusion <mach-ii-for-coldfusion@googlegroups.com>
Subject: [Mach-II] Re: sessions and application.cfc
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.
-------
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
On May 8, 3:10 pm, "Peter J. Farrell" <pe...@mach-ii.com> wrote:
> 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-coldfusion@googlegroups.com>
> Subject: [Mach-II] Re: sessions and application.cfc
> 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?
> 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
> On May 8, 3:10 pm, "Peter J. Farrell" <pe...@mach-ii.com> wrote:
>> 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-coldfusion@googlegroups.com> >> Subject: [Mach-II] Re: sessions and application.cfc
>> 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?
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
On Thu, May 8, 2008 at 11:11 PM, Peter J. Farrell <pe...@mach-ii.com> wrote:
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:
> 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
> On Thu, May 8, 2008 at 11:11 PM, Peter J. Farrell <pe...@mach-ii.com> wrote:
>> A few questions:
>> - Are you using ColdSpring to manage your model? >> - Do you have a session / user facade to leverage?
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