質問

How do I display a report showing all current seaside sessions along with their expected expiry time?

self session application sessionsDo: [:each | 
html text: 'Session For ',((each properties values at: 1) username),' Expires At: '.
html render: (Time now addSeconds: (each application cache expiryPolicy timeout)).
html break].

This, however, shows the wrong results in that it shows that all sessions expire at the same time, which is 600 seconds from Time now. I can't find another way to get at 'time remaining'.

WWLD? (What would Lukas do)?

KR Dusty

役に立ちましたか?

解決

The following code should do it:

WAApplication allInstances do: [ :application |
   application keysAndHandlersDo: [ :key :session |
      | policy table |
      policy := application cache expiryPolicy.
      table := policy instVarNamed: 'lastAccessTable'.
      Transcript 
        show: session; show: ' expires in '; 
        show: policy timeout - (Time totalSeconds - (table at: key));
        show: ' seconds'; cr ] ]

Note that the above code accesses internal data structures that might change in the future. Also you might need to add additional checks to make it work with your setup.

Also note that you might get negative seconds. This means that the session is supposed to disappear, but it hasn't been reaped yet.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top