[kpax-devel] And yet another question

Sven Van Caekenberghe scaekenberghe at common-lisp.net
Mon Jun 19 12:17:37 UTC 2006


Friedrich,

On 19 Jun 2006, at 11:29, Friedrich Dominicus wrote:

> is there a way to save an lisp object between pages?
>
> webactions has a nice feature with session-variable. I did not found
> anything in the examples (it seems the dispatching is done on some
> sort of id field). So I have to reconstruct the objects between the
> diverse pages. I wonder if it's possible to avoid that.

There is of course session support in KPAX !
Unless explicitly disabled, every web app does session tracking by  
default.

To access the session while handling a request, use get-session on a  
request-response.
The web-app-server, the web-app, the request-response and the session  
implement the attributes protocol using the attributes-mixin.

So storing something as session state, goes as follows:

(let ((session (get-session request-response)))
   (setf (get-attribute session :foo) 'foo))

On the next request-response cycle, you can retrieve the state as  
follows:

(let ((session (get-session request-response))
        (foo(get-attribute session :foo)))
    (print foo))

To debug, inspect *last-request-response* after a request-response  
cycle.

Please do check all the examples for more info.

HTH,

Sven

PS: session tracking can work with cookies (the default) or URL  
rewriting




More information about the kpax-devel mailing list