<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Sabine,<div class=""><br class=""></div><div class="">If you include a period check, you automatically keep the session alive if the ‘check in’ interval is shorter than the session expiration duration.</div><div class="">If the session is dead, the callback cannot execute because it is no longer there, so you cannot write code that checks if the session is still alive from within you Seaside code on the server.</div><div class=""><br class=""></div><div class="">You can only do something on the client, if the Seaside session is reported to be ‘dead’ (i.e. when receiving an http response 403).</div><div class="">Using an error handler for the jquery ajax requests is the way we deal with those situations. It boils down to this:</div><div class=""><br class=""></div><div class=""><div dir="ltr" class=""><div class="">        script:</div><div class="">            (html jQuery this load</div><div class="">                html: [ :r | … ];</div><div class=""><span class="Apple-tab-span" style="white-space:pre">          </span>onError: (html javascript alias: handleError))</div><div class="">               interval: 30 seconds);</div><div class="">        with: [ html render: something].</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">function handleError( event, jqxhr, settings, thrownError ) {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">     </span>if(jqxhr.status == 403)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">           </span>window.location = '/‘;</div><div class="">}</div><div class=""><br class=""></div><div class="">Instead of writing this for each ajax callback, you can also set a global ajax handler on the document when the page loads: <a href="http://api.jquery.com/category/ajax/global-ajax-event-handlers/" class="">http://api.jquery.com/category/ajax/global-ajax-event-handlers/</a></div><div class="">You might also want to take a look at this chapter: <a href="http://book.seaside.st/book/in-action/session/recovering" class="">http://book.seaside.st/book/in-action/session/recovering</a> if you want to respond in a specific way when sessions have expired</div><div class=""><br class=""></div><div class="">Does this help you?</div><div class=""><br class=""></div><div class="">cheers</div><div class="">Johan</div></div></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 20 Apr 2017, at 18:04, Sabine Manaa <<a href="mailto:manaa.sabine@gmail.com" class="">manaa.sabine@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi,</div><div class=""><br class=""></div><div class="">is anyone having an idea for a solution of this problem: </div><div class=""><br class=""></div><div class="">I want that my seaside web app redirects the user to another page (login page) if the session is "dead*". The special point I am looking for is: </div><div class=""><br class=""></div><div class="">This should happen ALSO if the user does NOT click on this page or does something. Also if the user switches to another tab. </div><div class=""><br class=""></div><div class="">So, if he comes back to the browser/to my apps tab, he should see a message "you have already been logged out".</div><div class=""><br class=""></div><div class="">I assume I have to periodically check if the session is alive and played around with </div><div class=""><br class=""></div><div class="">html paragraph</div><div class="">        script:</div><div class="">            (html jQuery this load</div><div class="">                html: [ :r | "here check for session and if not there, redirect"</div><div class="">                    (Array with: self currentPerson with: (self application sessions includes: self session))</div><div class="">                        inspect ];</div><div class="">                interval: 30 seconds);</div><div class="">        with: [ html render: something].</div><div class=""><br class=""></div><div class="">but if the session is dead, the code "here check ..." is no longer executed.</div><div class="">I am not sure if this is the right idea...</div><div class="">Anyone already implemented something like this?</div><div class=""><br class=""></div><div class="">I am not looking for a redirect after clicking somewhere in the app, I have this and it works fine. </div><div class=""><br class=""></div><div class="">Regards</div><div class="">Sabine</div><div class=""><br class=""></div><div class="">* I have read a little about "dead" sessions and know that they are collected away at unpredictable time. With "dead" I mean that if the user would click at the app, he would be transferred away.</div></div>
_______________________________________________<br class="">seaside mailing list<br class=""><a href="mailto:seaside@lists.squeakfoundation.org" class="">seaside@lists.squeakfoundation.org</a><br class="">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside<br class=""></div></blockquote></div><br class=""></div></body></html>