Skip to main content

Handling a Post-Session Request

We're not quite done because, while we have cleaned up on the server, our Web page may still be displayed on the user's browser. He or she could subsequently click on the Complete Order button, unaware that the session has been closed.

To address this, we're going to enhance the TicketConfirm page that gets displayed when the Complete Order button is pressed. We add code to check whether we have an order pending (by looking for an Order value in the %session object.) If not, we display a message.

Note that, if a session is ended as a result of a time out, the %session object associated with that session (and any data we stored in the %session object) is gone. Any subsequent request from the user is part of a new session with a new %session object.

—TicketConfirm.OnPage—
TicketConfirm.OnPage
ClassMethod OnPage() As %Status
{
    &html<<html>
    <head>
    </head>
    <body>>
    If ($D(%session.Data("Order"))) {
        Do ..CompleteOrder()

        Write "Thank you for using Caché Cinema!<br>",!
    }
    Else {
        Write "Your order expired before it was completed."
    }
    &html<</body>
    </html>>
    Quit $$$OK
}
FeedbackOpens in a new tab