lindleycb / meteor-stale-session

Stale session and session timeout handling for meteorjs
MIT License
40 stars 20 forks source link

Configuring to log off after browser close #1

Closed wbashir closed 10 years ago

wbashir commented 10 years ago

Thanks for this session management plugin, I was looking to see if there is a way to always log the user off if they close the current browser and to terminate all their sessions ?

lindleycb commented 10 years ago

Hi,

That wasn't really a problem I was looking to solve with this plugin and from what I just read here http://stackoverflow.com/questions/3888902/javascript-detect-browser-close-tab-close-browser detecting browser close in javascript is not straight forward!

However, by tweaking the Meteor.settings on this plugin to be more frequent you might get a close approximation of the desired effect in that the absence of a heartbeat will have the server close all sessions.

So, if you set the heartbeat, poll and timeout intervals to suitably short values, the server should close all sessions shortly after browser close - though at the cost of some performance due to the frequent polling. Note, however, that, as all sessions send heartbeats, you'd have to close browser/tab on all sessions to stop the heartbeat and that kind of defeats the object or does it?!

Not sure this was a very helpful answer but good luck solving the problem!

Chris

wbashir commented 10 years ago

Thanks for answer, that helps. Detecting a browser close event is hard but since i am able to at least log users off due to inactivity, that should suffice for now.