NetTalk Central

Author Topic: NT 6 to NT 7 app upgrades  (Read 7469 times)

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Re: NT 6 to NT 7 app upgrades
« Reply #15 on: December 18, 2012, 08:11:09 AM »
I have the same issue....most of my apps were created with the app wizard and thus have just the login page.  In NT6 apps, this was the only page used during login and log out. 

Looking at the web3 example, I noticed a new logout form page.  It has embedded code to log out and delete the session.  So I copied this form page to my apps.  It does the log out and deletes the session and no stray menu items remain when they should not.  However, if I try to use this as a pop up, it does not work.

I also noticed in the web3 example, there is an option to logout with JavaScript code.  So I started adding this to my NT7 apps and now my logouts behave as they did in NT6.

Thanks,

Jeff

JPMacDonald

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • Email
Re: NT 6 to NT 7 app upgrades
« Reply #16 on: December 18, 2012, 08:49:32 AM »
Bruce,

Using my own logout page with a confirmation request "Are your sure..." works and now my cleanup embed gets executed and the menu items are taken care of.

However, if the browser session times out the user is automatically redirected to the Login Form and now my cleanup code does not get executed and the menu items are all still visible.

Any clues on how to handle logout logic when the session times out?

Regards

Parker

JPMacDonald

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • Email
Re: NT 6 to NT 7 app upgrades
« Reply #17 on: December 18, 2012, 09:30:07 AM »
Bruce,

Not sure if you would approve of this approach or not but here is a work around for me, I am sure you will have a more elegant solution.

Created a new Procedure called LogoutRedirect
    In the XHtml after head I put this code (angle brackets not shown but should be there)
        meta HTTP-EQUIV="REFRESH" content="0; url=indexpage"
    Gave the Routine the name of Redirect

In the Redirect Routine embed code I put the p_web.SetSessionLoggedIn(0)

In the WebServer settings I changed my LoginPage to: LogoutRedirect (that feels counter intuitive doesn't it?) This will catch the session timeout.

In the Logout Menu Item I set the procedure to LogoutRedirect as well.

Now both scenarios seem to be coverd and my cleanup code gets called regardless of the user selecting to logout or if the session times out.

Since the Redirect is to a page within the same site web browsers shouldn't complain about the redirection, or so I hope.

Regards

Parker

JPMacDonald

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • Email
Re: NT 6 to NT 7 app upgrades
« Reply #18 on: December 18, 2012, 11:08:29 AM »
Damn, forgot the 3rd scenario, when a user just abondons the page by closing the browser and walks away, under that conditin my cleanup code does not get executed.

Back to the drawing board.

Parker

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: NT 6 to NT 7 app upgrades
« Reply #19 on: December 18, 2012, 10:53:40 PM »
>> Damn, forgot the 3rd scenario, when a user just abondons the page by closing the browser and walks away, under that conditin my cleanup code does not get executed.

If your clean-up code is in the DeleteSession method then it'll get called when the session times out - which is what will happen if they just walk away.

cheers
Bruce

JPMacDonald

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • Email
Re: NT 6 to NT 7 app upgrades
« Reply #20 on: December 19, 2012, 07:06:46 AM »
Bruce,

Of course you are correct, the routine is getting called on the timeout but here is what I discovered in my app.

I have a couple of in-memeory tables that I use for "tagging" records and for special filters I use throughout the application. The code below is part of my cleanup process and it works if the user logs out, if the session times out with the browser open, but does not delete anything from the memory tables if they just close the browser.

RemoveEmpFilters     ROUTINE
   FIL:SessionID = Clip(p_web.SessionID)
   FIL:FilterID  = ''
   SET(FIL:Primary,FIL:Primary)
   LOOP
      Access:Filters.Next()
      IF Errorcode() THEN BREAK.
      IF FIL:SessionID <> p_web.SessionID THEN BREAK.
      Access:Filters.DeleteRecord(0)
     p_web._Trace('Actually Deleted a filter')
   END

I've changed this to NOT use the ABC File manager syntax so it now looks like this and now it seems to work (I'll need to test it more to be sure).

   OPEN(Filters)
   FIL:SessionID = Clip(p_web.SessionID)
   FIL:FilterID  = ''
   SET(FIL:Primary,FIL:Primary)
   LOOP
      Next(Filters)
      IF Errorcode() THEN BREAK.
      IF FIL:SessionID <> p_web.SessionID THEN BREAK.
      Delete(Filters)
     p_web._Trace('Actually Deleted a filter')
   END

Regards

Parker

JPMacDonald

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • Email
Re: NT 6 to NT 7 app upgrades
« Reply #21 on: December 23, 2012, 12:30:15 PM »
Hi all,

I need to declare my "fix" to this as unstable at the moment.

While the code seemed to work for all 3 exit scenarios (menu Logout, browser timeout, and browser close) the web server hangs after a short period so my code is not a workable fix.

I think it best if I start from square one.

Regards

Parker