Hi, is anyone having an idea for a solution of this problem: 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: This should happen ALSO if the user does NOT click on this page or does something. Also if the user switches to another tab. So, if he comes back to the browser/to my apps tab, he should see a message "you have already been logged out". I assume I have to periodically check if the session is alive and played around with html paragraph script: (html jQuery this load html: [ :r | "here check for session and if not there, redirect" (Array with: self currentPerson with: (self application sessions includes: self session)) inspect ]; interval: 30 seconds); with: [ html render: something]. but if the session is dead, the code "here check ..." is no longer executed. I am not sure if this is the right idea... Anyone already implemented something like this? I am not looking for a redirect after clicking somewhere in the app, I have this and it works fine. Regards Sabine * 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. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hi Sabine,
If you include a period check, you automatically keep the session alive if the ‘check in’ interval is shorter than the session expiration duration. 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. 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). Using an error handler for the jquery ajax requests is the way we deal with those situations. It boils down to this: script: (html jQuery this load html: [ :r | … ]; onError: (html javascript alias: handleError)) interval: 30 seconds); with: [ html render: something]. function handleError( event, jqxhr, settings, thrownError ) { if(jqxhr.status == 403) window.location = '/‘; } Instead of writing this for each ajax callback, you can also set a global ajax handler on the document when the page loads: http://api.jquery.com/category/ajax/global-ajax-event-handlers/ You might also want to take a look at this chapter: http://book.seaside.st/book/in-action/session/recovering if you want to respond in a specific way when sessions have expired Does this help you? cheers Johan
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hi Johan, yes, it helped, thank you! onError: did not work but I already had a global error handler and this works fine. Have a nice day Sabine 2017-04-21 8:13 GMT+02:00 Johan Brichau-2 [via Smalltalk] <[hidden email]>: Hi Sabine, |
Free forum by Nabble | Edit this page |