Hi Kahlil,
Have you taken a look at System Events?

In here you can centralize actions to run when a session starts (action to be executed in the first request to the server, after logging in, or on the first request after having logged out) or when a web request begins (action to be executed on each request to the server.), so you don't have to repeat it every time.
Note: this only applies for Traditional Web where session is maintained server side.
Hope it helps.
Regards,
João