#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0

    Display Last Login


    Hi,

    I haven't been able to find any info on how to do something like this with Postgres.

    I am looking for a way to configure Postgres such that when a user logs in (interactively, on the command line), the date/time of the last successful login (or number of unsuccessful logins since) gets printed to the screen.

    I'm not sure if this is already a feature of Postgres, or if there is some sort of "welcome message" configuration, or if I need to create a trigger (can you make a login trigger?).

    Is this sort of thing feasible with Postgres? I am using Postgres 9.1.6 in a Windows environment.

    Thanks,
    Douglas
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,777
    Rep Power
    348
    I don't think this is possible.

    PostgreSQL does not store the last login. You could enable logging the connections, but that would go into the logfile.

    Additionally there is no way to e.g. have a trigger that is executed when someone logs in. So even if you had the information available (e.g. by parsing the logfile) there is no place where you could run that code.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

IMN logo majestic logo threadwatch logo seochat tools logo