Execute an action / run a trigger every time a User logs in to Salesforce

Couple of options to consider:

  1. Throw a Visualforce page into the sidebar component and either update the user record (or directly perform the logic you need to capture "login" event.
  2. Have a VF page and set that as the default page for the default App. Everytime the user logs in this page will get executed and then you can redirect to the tab/page that you want the user to go.

With #1, since Reports &Admin setup pages don't get the side bar, this might not work in those pages. So if a user had bookmarked a setup page, side bar component will never get executed.

With#2, if a user bookmarks a page, the default app/page is not used and hence the VF page will not be run.

What are you trying to achieve with this trigger? Given you are concatenating Session Id (which is temporary) not really sure what you are aiming to do.

Perhaps a use cae would help to provide better answers.


Not sure if this thread is still active.You can use the login flows. Create a class with an invokable method and refer this class in flow by creating a new flow. Now create a login flow to invoke this newly created flow.