Re: Session ID -- Again (How to implement single session login)
Posted in 1996
Chao Y. Din wrote:
>
> Sorry for late response to an old issue: How to acquire session id?
>
> Based upon the previous discussion, it is not an issue for OnLine 7.2, because 7.2 offers a
> new function DBINFO.
>
> However for OnLine prior to 7.2, there is a work-around:
>
> Select the maximum session id with your user id right after
> you log in the database.
>
> In our applications, we select count for the same user id. If it is more than one, we
> ask user whether they want to kill old connections. Once users confirm to kill the
> previous connections, we kill all processes except the maximum session id. The program has
> been running for almost two months. So far there isn't a single complain.
>
> Chao Din
This is a neat idea, but I have a couple of comments. First, I'm not sure if selecting
the maximum session id is bullet-proof. It occurs to me that if the same user logs in
twice at about the same time, one of the sessions might kill himself (no big deal in your
particular case). Also there is the question of whether the maximum session id is
guaranteed to be the the latest one.
A better way might be to find your session id by process id, as in:
select sid from sysmaster:syssessions where pid = my_pid
You can also count sessions that don't have your pid. Getting the pid value is another
story but it's trivial in i4gl or esqlc.
----------------------------------------------------------------------
John H. Frantz Power-4gl: Extending Informix-4gl
frantz@centrum.is http://www.strengur.is/~frantz/pow4gl.html