Deleting CSP session

128 views
Skip to first unread message

Michoel Reach

unread,
Mar 31, 2021, 11:22:23 AM3/31/21
to IRIS, Caché, Ensemble
I have a background job that keeps an eye on our ongoing CSP sessions, counts licenses used and other tasks. Question: If I know the session ID (something like "wuuZ2Gwgxw"), how do I end that particular session programmatically in ObjectScript - i.e., the equivalent of %session.EndSession=1 in the csp page code?
Thanks!
Michael Reach

pavlov...@alanov.ru

unread,
Apr 1, 2021, 1:15:18 AM4/1/21
to IRIS, Caché, Ensemble
The  obvious way would be opening that session by id and setting EndSession=1, however it might not work every time since the session object is locked by its owner process.

1.
There is is query SessionInfo in class %CSP.Session, which returns some AllowEndSession flag, however, I don't know if it's of any use
Set rs = ##class(%ResultSet).%New("%CSP.Session:SessionInfo")
w rs.Execute()
w rs.Next()
w rs.Get("ID")
DLnrk47Qyg
w rs.Get("AllowEndSession")
0

2. If you could find the ID of the process which the session belongs to, you could end the process by 
$System.Process.Terminate(Process ID)
However, I could not find a clear way to connect the session with process, maybe because one session could be used by different processes sequentualy
Maybe the 
%CSP.Session:SessionInfo
%SYS.LockQuery
%SYS.ProcessQuery
could be of help to you, but for some reason, doing 
Set rs = ##class(%ResultSet).%New("%SYS.LockQuery:List")
Do rs.Execute()
While rs.Next() { Write rs.Get("LockString"),! }
does not return the session lock reference, while it's cleary there in Portal Page, which is strange

I'm pretty sure that a dive into actual globals containing session info could solve this

3. You might want to ask this question at community.intersystems.com, since these mail lists are not very active
среда, 31 марта 2021 г. в 22:22:23 UTC+7, Michoel Reach:

Michoel Reach

unread,
Apr 1, 2021, 9:06:15 AM4/1/21
to IRIS, Caché, Ensemble
Thank you! I did ask over there, and got some answers. But it seems like it is hard, which surprises me a little.
But if I could ask, what do you mean exactly by "opening that session by id etc."? That sounds like exactly what I'm asking for - how is that done?
Michael

kiberd...@gmail.com

unread,
Apr 2, 2021, 4:53:28 AM4/2/21
to IRIS, Caché, Ensemble
CSP session is a %Persistent object, it could be opened as usual

Set o=##class(%CSP.Session).%OpenId("Uy5IRImTak")
zw o
<OBJECT REFERENCE>[1@%CSP.Session]
+----------------- general information ---------------
|      oref value: 1
|      class name: %CSP.Session
|           %%OID: $lb("Uy5IRImTak","%CSP.Session")
| reference count: 2
+----------------- attribute values ------------------
|       %Concurrency = 1  <Set>
|         AppTimeout = 28800
|        Application = "/csp/sys/op/"  <Set>
|ApplicationLicenses = ""
|        BrowserName = ""  <Get>
|    BrowserPlatform = ""  <Get>
|     BrowserVersion = ""  <Get>
...

And you actually can just delete it too, I did
zw ##class(%CSP.Session).%DeleteId("Uy5IRImTak")
1

and I'm logged out of Management Portal, neat
However, I'm not sure why if I log back, the new session has the same ID.

CSP Session is a persistent object, stored between requests. When someone access csp page it's not like there always an open connection, the data stored in session is stored on the server side.
When a new request arrives, Cache uses CSPSESSIONID cookie from request to restore the corresponding session, basically to %Open it. That's how I understand it.
четверг, 1 апреля 2021 г. в 20:06:15 UTC+7, Michoel Reach:

Michoel Reach

unread,
Apr 2, 2021, 8:41:42 AM4/2/21
to IRIS, Caché, Ensemble
Thanks!
Reply all
Reply to author
Forward
0 new messages