NetTalk Central

Author Topic: What embed execute Session expire?  (Read 4127 times)

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
What embed execute Session expire?
« on: August 19, 2014, 10:44:55 PM »
Hallo,


I would like to inject some code in the embed when this code excute.

Code: [Select]
[i]  if (p_web.GetSessionLoggedIn() AND p_web.PageName <> clip(p_web.site.LoginPage))
    ! parameter 1 is the session time
    ! parameter 2 is the name of the login page.
    ! parameter 3 is the id of the <div> in the html.
    stt.Trace('== countdown start ==')
    p_web.Script('startCountDown('& int(p_web.site.SessionExpiryAfterHS/100) &',"'& clip(p_web.site.LoginPage) &'","countdown");')
  end"[/i]

How can I detect and what code to write to know if session expire?

Thank you,
Robert

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: What embed execute Session expire?
« Reply #1 on: August 20, 2014, 12:02:56 AM »
your code needs to go into the NotifyDeleteSession method in the webhandler

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: What embed execute Session expire?
« Reply #2 on: August 20, 2014, 01:37:29 AM »
Hallo Kevin,

I put a trace on NotifyDeleteSession method in the webhandler and nothing there... when session expires this method is not called.

Robert

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: What embed execute Session expire?
« Reply #3 on: August 20, 2014, 09:40:57 PM »
Hi Robert,

>> I put a trace on NotifyDeleteSession method in the webhandler and nothing there... when session expires this method is not called.

Yeah this method does get called when the session expires. The key is understanding when it is that the session _actually_ expires.

If you use the count-down timer then a URL is triggered when the count-down expires. But that call can have the effect of "touching" the session, and hence extending it for a further period. So the user is told "The session has ended" but in fact the session may actually exist for another cycle (typically 15 minutes.)

You can set your session time really short (1 minute) for testing.

cheers
Bruce


Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: What embed execute Session expire?
« Reply #4 on: August 21, 2014, 05:53:52 AM »
Hallo Bruce,


>>If you use the count-down timer then a URL is triggered when the count-down expires. But that call can have the effect of "touching" the session, and hence extending it for a further period. So the user is told "The session has ended" but in fact the session may actually exist for another cycle (typically 15 minutes.)

This is correct I tested before and I knew after the session expire will open the login form and it will extend again the session with another xx minutes you have setup in template.
For my project it was necessary to know when this session expire because I develop a mechanism to show user online and how much time they spend in one session. My code for logout is on Webhandler > DeleteSession. This works perfect. But when session expire then I have to wait again xx minutes until this embed execute the code so this will not reflect correct time spend for a user in that session.

Now I made a trick. I put a parameter on the link "?sessionexpire=1"

Code: [Select]
p_web.Script('startCountDown('& int(p_web.site.SessionExpiryAfterHS/100) &',"'& clip(p_web.site.LoginPage) &'?sessionexpire=1'&'","countdown");')
and I read this parameter on the login page. If true then my code execute. For the moment it works ok.

If anyone have better method please share :o)

Thank you,
Robert

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: What embed execute Session expire?
« Reply #5 on: August 21, 2014, 05:57:09 AM »
>> the session expire will open the login form

you should not expire to a "Form" - especially not the login form.
Rather expire to a "page".

cheers
Bruce

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: What embed execute Session expire?
« Reply #6 on: August 21, 2014, 06:32:58 AM »
Cool! and this way I don't need that parameter. ;-)  I will put just a link to login page.
Thanks,
Robert