Make use of session variable for this kind and have a icon button in green and black color.
Let be in the master page.
In the master page load event, just chech the session variable and if it is null or empty, make the image as black which indicates the user is offline.
If there is value in the session , then set the green image in the master page load.
When even user successfully loged in, the set the session value and when the master page is rendered, it will check for the session value and set the green image.
Hope this may help you.
Thanks.