PostgreSQL set session variable

Viewed 6356

My app which connects to PostgreSQL DB using same credentials (db provider requirement...) However I need to recognize what app user is connecting to DB (eg for udates auditing etc)

I wonder if there is any way I can set some variable (which life is limited to session only), which then I can somehow read via DDLs.

** EDIT **

Ive also did some experiments using application_name in conneciton string and putting there simple user login - but this is not most elegant way...

SET application_name TO 'user_login';
select current_setting('application_name');

Any idea how to archive that ?

1 Answers
Related