[Twisted-Python] twisted.web session expiry
I need someone to help me with twisted.web. How can I do something (eg. redirect) once a users session has expired? At the point when the session expires your request is finished and your session is expired. I have added the notification callback but I can't really do anything inside it without a session to store information in or a request to redirect with, so I just print a message to the console. Can anyone help me understand what I'm doing wrong here? Thanks Daniel Browne
I don't see how this would work, as HTTP is a stateless protocol.
Should by possible with AJAX, though (so, athena.livepage may be your
friend).
2008/8/22 Daniel Browne
I need someone to help me with twisted.web.
How can I do something (eg. redirect) once a users session has expired? At the point when the session expires your request is finished and your session is expired. I have added the notification callback but I can't really do anything inside it without a session to store information in or a request to redirect with, so I just print a message to the console.
Can anyone help me understand what I'm doing wrong here?
Thanks Daniel Browne
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
On Aug 22, 2008, at 10:05 AM, Daniel Browne wrote:
I need someone to help me with twisted.web.
How can I do something (eg. redirect) once a users session has expired? At the point when the session expires your request is finished and your session is expired. I have added the notification callback but I can't really do anything inside it without a session to store information in or a request to redirect with, so I just print a message to the console.
Can anyone help me understand what I'm doing wrong here?
I can see where that would be a bit tricky. The best idea I can think of is to have your top-level Resource check the session state in the locateChild method. If the session has expired, you can return a special Resource that simply redirects immediately. -phil
Daniel Browne
How can I do something (eg. redirect) once a users session has expired? At the point when the session expires your request is finished and your session is expired. I have added the notification callback but I can't really do anything inside it without a session to store information in or a request to redirect with, so I just print a message to the console.
If you're trying to cause something to happen on the user's browser when their session expires, as others have pointed out default HTTP is stateless, so without something (like a bit of Javascript) running in the user's browser staying in contact with your server behind the scenes you won't be able to trigger any behavior on their end. A user is likely to be already familiar with how most sites that have active sessions won't tell them that their session is expired until they initiate a subsequent request to the server (refresh a page, try to click on a link, etc...). Barring unique requirements for your application, simply behaving that way - check the session for possible expiration upon any subsequent request from that user and issue the redirect then if expired - should be a fairly common behavior. If you want to have something on the server end occur when the session expires (say to update some internal state, or adjust or clear the session information), then you can just establish a standard Twisted callLater callback (which could itself be stored in the session and reset when requests did come in), or if you may have lots of sessions, have a separate server side object with a single periodic timer take care of expiring sessions. Or any other server side event that occurs could be used to initiate session expiration processing. -- David
participants (4)
-
Daniel Browne
-
David Bolen
-
Phil Christensen
-
Sebastian Schulze