[英]Reporting on Seaside Sessions, such as time to expirey
如何顯示顯示所有當前海邊會話及其預期到期時間的報告?
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].
但是,這顯示了錯誤的結果,因為它顯示所有會話同時到期,距現在時間600秒。 我找不到另一種方法來“剩余時間”。
WWLD? (盧卡斯會做什么)?
KR Dusty
以下代碼應該這樣做:
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 ] ]
請注意,上述代碼訪問將來可能會更改的內部數據結構。 此外,您可能需要添加其他檢查以使其適用於您的設置。
另請注意,您可能會獲得負秒數。 這意味着會話應該會消失,但還沒有收到。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.