Session ID -- Again (How to implement single session login) 
Author Message
 Session ID -- Again (How to implement single session login)

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



Wed, 18 Jun 1902 08:00:00 GMT
 Session ID -- Again (How to implement single session login)

Quote:

> 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



Wed, 18 Jun 1902 08:00:00 GMT
 Session ID -- Again (How to implement single session login)

Quote:


> > Sorry for late response to an old issue:  How to acquire session id?
> > ....
> > 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.

Actually, the discussion is meaningless now, because I just found DBINFO is available since ONLINE 6.0.  
However, I still want to address some of the issues you brought up.  First of all, I have never said our
approach is bullet-proof.

Quote:
> 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).

The senario cannot happen in our environment.  Every user has his/her own computer and they can only use their
own account.  They have to run to another computer in order to log in from two different computers and mess up
the max session id.

Quote:
> Also there is the question of whether the maximum session id is
> guaranteed to be the the latest one.

I am sure there is no guarantee even before we start using the max session id.  But I did not have a choice.  
There
was no other way to implement that.

Quote:

> 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.

Your approach does not apply in our environment.  Our clients are PCs runing Powerbuilder.  Since clients talk
to server through I-NET and then TCP/IP session, pid is always "-1".

Chao



Wed, 18 Jun 1902 08:00:00 GMT
 Session ID -- Again (How to implement single session login)

Quote:

>>...
>>Actually, the discussion is meaningless now, because I just found DBINFO is
>>available since ONLINE 6.0.
>>...

>What does DBINFO do for you here? According to my manuals, DBINFO gives you
>things like sqlerrd1, sqlerrd2 and DBSPACE, but how do you use it to find
>out your session ID?

Sorry, I made a mistake again.  I though DBINFO('sessionid') is an undocumented function, but....

Anyway, DBINFO('sessionid') in only available in OnLine 7.2.

Chao



Wed, 18 Jun 1902 08:00:00 GMT
 Session ID -- Again (How to implement single session login)

Quote:

>...
>Actually, the discussion is meaningless now, because I just found DBINFO is
>available since ONLINE 6.0.
>...

What does DBINFO do for you here? According to my manuals, DBINFO gives you
things like sqlerrd1, sqlerrd2 and DBSPACE, but how do you use it to find
out your session ID?

Quote:
>...
>Your approach does not work in our environment.  Our clients are PCs runing
>Powerbuilder.  Since clients talk to server through I-NET, pid is always "-1".
>...

OK, I suspected that. If you have a bullet proof way to get the session ID that
would work for all environments, please let me know.

----------------------------------------------------------------------
John H. Frantz           Power-4gl: Extending Informix-4gl



Wed, 18 Jun 1902 08:00:00 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. dynamically created session and database : cannot avoid login prompt - fine with default session

2. Current Session ID (SID) v$session

3. User restricted to a single Login/Session

4. 2. Level Login and session ID

5. Linking Unix Process Id's back to Session Id's

6. Query to tie Rollback to Session ID/Process ID

7. Java programs running on a Windows NT session via a server session

8. kill session vs kill session immediate

9. How to create ADO session over OLEDB session?

10. Revelation: PUSH.SESSION/POP.SESSION

11. Help: Can we alter session for other sessions

12. v$session, aborted sessions


 
Powered by phpBB® Forum Software