chickadee » awful » define-session-page

define-session-page path-matcher handlerr #!rest restprocedure

Define a session-aware page. When the page is accessed and a corresponding session does not exist, it is created. If the session already exists and is not valid, it is recreated. If the session already exists and is valid, then it is refreshed.

The rest parameters are the same as for define-page.

Here's an example (the arc challenge):

(use awful)

(enable-sxml #t)

(define-session-page "said"
  (lambda ()
    (with-request-variables (said)
      (cond (said
             ($session-set! 'said said)
             `(,(link "said" "click here")))
            (($session 'said)
             => (lambda (said)
                  `("You said: " ,said)))
            (else `(,(form '((input (@ (type "text") (name "said")))
                             (input (@ (type "submit"))))
                           action: "said"
                           method: 'post))))))
  method: '(GET POST))