NetTalk Central

Author Topic: Delete record on browser closed  (Read 5606 times)

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
Delete record on browser closed
« on: December 17, 2012, 03:34:21 AM »
I have a site that users have to login and when they logout a particular record as to be deleted, so i was using the session deleted to delete this record when they logout but in some suitation when they just close browser without logging out i need to delete the record and i have put a timeout on sessions and try and delete after timeout deletes session but that seems not to work . The only way is when they logout.
Please anybody on how i can solve this problem.
(Note: program is run on a the multi-host program as a dll - but when i run program on its own without going through the multi-host program (host.exe) it works fine!)

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Delete record on browser closed
« Reply #1 on: December 17, 2012, 10:32:27 PM »
I should get a chance to review this this week Olu.

cheers
Bruce

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
Re: Delete record on browser closed
« Reply #2 on: January 09, 2013, 03:04:12 AM »
please bruce this is still a issue, have had a chance to look at this.

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
Re: Delete record on browser closed
« Reply #3 on: January 22, 2013, 02:58:17 AM »
hi bruce this is still a issue, you promised to review this, have you had a chance to look at this.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Delete record on browser closed
« Reply #4 on: January 23, 2013, 02:01:21 AM »
Hi Olu,

yes, I've been looking into this.
the key is;

>> (Note: program is run on a the multi-host program as a dll - but when i run program on its own without going through the multi-host program (host.exe) it works fine!)

What's happening here is that the session "belongs" to the server - which in this case is the host. The server (in this case the host) will do the garbage collection (ie cleaning up abandoned sessions) and obviously will use it's own WebHandler to do this.

There's no mechanism to "pass this information" to all the DLL's - and therein lies your real problem. The code you've written is obviously in the DLL (where it belongs) but the Host does all the work.

I am investigating possible ways of "alerting" the handlers that a session is about to be deleted, but even that is far from a trivial thing to do. There are threads involved here which mean things could get very icky very quickly if the DLL isn't completed by the time the host starts deleting the session details.

Hopefully I'll come up with a solution.

cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Delete record on browser closed
« Reply #5 on: January 23, 2013, 10:05:55 PM »
Hi Olu,

Ok, I've found a solution. This will be in the 7.03 build. Note that code in the Host app has changed, so you'll need to update your host (and of course recompile any DLL's attached to the host.)

I've added a method to the WebHandler called .NotifyDeleteSession.
This is called by your app just before a session is deleted, and by the server (probably*) just after a session is deleted.

So first rule - you can access self.sessionid in here, but you can't access SessionValues or any other session related data. In your case you have the session id, and that's all you need to clean up your ancillary files.

(*) - the reason for saying "probably" is because this is called on it's own thread - with one thread per Host in your site list. A thread is also started by the server itself which will actually delete the sessions. It's impossible to determine the order the threads will run in, or where each thread will be at any time. So for the NotifyDeleteSession threads, they should assume that the Session itself has already been deleted.

Cheers
Bruce

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
Re: Delete record on browser closed
« Reply #6 on: January 24, 2013, 12:10:49 AM »
Hi Bruce,
  Thanks a lot that sounds great! Now can wait to see 7.03.