Is it possible to get a List of all active Sessions?

时光怂恿深爱的人放手 提交于 2020-01-04 04:07:13

问题


When being in a Grails action I can access a HTTPSession with session.

Is it also possible to get a list of all active sessions?


回答1:


You can use getSessionsInfo() method of ScopesInfoService service of Application Info plugin.

First install plugin(in BuildConfig)

compile ":app-info:1.0.2"{
        excludes 'jquery'
}

then make an entry in Config

grails.plugins.appinfo.useContextListener = true

finally inject service and use its getSessionsInfo() method

def scopesInfoService
...
scopesInfoService.getSessionsInfo()

to get the list of all active sessions.




回答2:


This is the answer to your question in comments:

I was able to get it work with 2.2.4, without any issue. Make sure you read this blog for compatibilities with grails 2+.

To exclude the jquery version use:

compile (":app-info:1.0.2" ){
            excludes 'jquery'
}

This way your are telling Grails not to use plugins' jquery but your app.



来源:https://stackoverflow.com/questions/18161974/is-it-possible-to-get-a-list-of-all-active-sessions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!