Re: redirect user if session dead without clicking him at the page itself
Sabine Manaa <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <CA+UbgZbf0fK2yr7vGg4DVsXEDbKmrGrjnPCE+fzjHPFiMd7ECg@mail.gmail.com> |
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] < [email protected]>: > 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 > > On 20 Apr 2017, at 18:04, Sabine Manaa <[hidden email] > <http:///user/SendEmail.jtp?type=node&node=4942970&i=0>> wrote: > > 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:///user/SendEmail.jtp?type=node&node=4942970&i=1> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > > > _______________________________________________ > seaside mailing list > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4942970&i=2> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > http://forum.world.st/redirect-user-if-session-dead- > without-clicking-him-at-the-page-itself-tp4942774p4942970.html > To start a new topic under Seaside General, email > [email protected] > To unsubscribe from Seaside, click here > <http://forum.world.st/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1310907&code=bWFuYWEuc2FiaW5lQGdtYWlsLmNvbXwxMzEwOTA3fC0xOTE3OTcxOTg5> > . > NAML > <http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://forum.world.st/redirect-user-if-session-dead-without-clicking-him-at-the-page-itself-tp4942774p4943036.html Sent from the Seaside General mailing list archive at Nabble.com. _______________________________________________ seaside mailing list [email protected] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside