Session ID

Hi all,

Thanks for your continued support.

When a user logs in through the application i need to get his session id (which should be unique) and whenever he makes a change to the data i should be able to identify him through this session id . how do i do it , how can identify the session id and use it later on when that user makes some changes.

Please let me know if i am not clear enough.

many thanks.
crishna1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jonva13Commented:
If you have access to it, all of this information is on the v$session view.  
(DESC v$session)
0
 
crishna1Author Commented:
That was helpful, but the USERS who login through the application does not have DBA privilage.

How to hadle it when the user does not have access to the v$ tables ? How to get information like OS_USER, USER_ENV, SESSION ID etc.

many thanks.
0
 
crishna1Author Commented:
never mind "SELECT SYS_CONTEXT('USERENV','OS_USER') UserId FROM Dual" answers all my questions.
0
 
jrb1Commented:
Some info from v$session is availble through functions:

USERNAME - function USER : select USER from dual;
AUDSID - function USERENV: select USERENV('SESSIONID') from dual;
TERMINAL - function USERENV: select userenv('TERMINAL') from dual;

Also, there is a UID function which gives you the number that matches a user on DBA_USERS:

select UID from dual;

Another way would be to create a function that returns the information you desire.  For session ID,

create or replace function GetSID return number is
   sessn number;
begin
  select sid
  into sessn
  from v$session;
  return sessn;
end;
/

You could create a whole package of these types of functions.  You have to have direct access to v$session to create the function (not through a role).  Then if you grant access to the functions to the users (or PUBLIC) they will be able to retrieve these results.

0
All Courses

From novice to tech pro — start learning today.