
Anthony C. answered 09/24/19
Knowledgeable and Experienced Programmer Offering Tech Tutoring
First off, this requires the use of server-side scripting. Let's assume that you have a logged in user in PHP, and that the path to that user's favicon is at $_SESSION['favicon']. You want to then generate a custom favicon <link> tag using php.
In this case, you are pulling the favicon URI from the PHP session (the code above assumes that this variable holds the absolute or relative path to the favicon from the current directory... ensure that it does, or modify the echo accordingly. The query string is included to encourage the page to load the image, not pull from cache, which might yield the wrong image.
**Note** This will increase page load times, and might cause caching issues like Cache collision on Firefox.
https://github.com/audreyr/favicon-cheat-sheet
See the section on "forcing a favicon refresh".