[Seaside] visitor information

radoslav hodnicak rh at 4096.sk
Tue Nov 9 17:12:08 CET 2004


On Tue, 9 Nov 2004, Jim Menard wrote:

> For each visitor to a Web site, I need to track a few things: if he's logged
> in, where in the navigation hierarchy he is, and more. In Java, I'd save that
> information in an object and save the object in the session. How is it done in
> Seaside? I've looked at WASession, but don't see any obvious methods for
> storing and retrieving values.

Others have instructed you how to make your own session subclass, I'd just
add that to find what component the user is displaying you can add an
instvar "currentPresenter" to your session class and add
"self session currentPresenter: self" to WAPresenter>>renderWithContext:
This is useful to create some statistics of connected users and what they
are doing.

Another goodie for such statistics is to add this to your session class

connectedFrom

  | addr bytes name |
  addr := self currentRequest headers at: 'x-forwarded-for' ifAbsent: ['???'].
  bytes := NetNameResolver addressForName: addr timeout: 10.
  bytes ifNil: [^addr].
  name := NetNameResolver nameForAddress: bytes timeout: 10.
  ^name ifNil: [addr]

This works if you run seaside behind a web server, if you use comanche
directly the client IP is stored in request as well.

rado



More information about the Seaside mailing list