Dynamic Web Development with Seaside

Buy PDF Buy Print

18.4Lifecycle of a Session

It is important to understand the lifecycle of a session to know which hooks to customize. Figure 132 depicts the lifetime of a session:

  1. When the user accesses a Seaside application for the first time a new session instance is created and the root component is instantiated. Seaside sends the message WAComponent>>initialRequest: to the active component tree, just before triggering the rendering of the components. Specializing the method initialRequest: enables developers to inspect the head fields of the first request to an application, and to parse and restore state if necessary.
  2. All subsequent requests are processed the same way. First, Seaside gives the components the ability to process the callbacks that have been defined during the last rendering pass. These callbacks are usually triggered by clicking a link or submitting a form. Then Seaside calls WAComponent>>updateUrl: of all visible components. This gives the developer the ability to modify the default URL automatically generated by Seaside. Then Seaside redirects the user to the new URL. This redirect is important, because it avoids processing the callbacks unnecessarily when the user hits the Back button. Finally Seaside renders the component tree.
  3. If the session is not used for an extended period of time, Seaside automatically expires it and calls the method WASession>>unregistered. If the user bookmarked the application, or comes back to the expired session for another reason, a new session is spawned and the lifecycle of the session starts from the beginning.

Lifetime of a session

Copyright © 20 November 2017 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.