One approach (if you don't care too much about tracking notifications and who saw them) is to have a table that stores notifications for users, and then delete this line when they reject the notification.
For example, if they get an icon:
INSERT INTO NOTIFICATIONS.....
THEN when they clean it (via AJAX I guess)
DELETE FROM NOTIFICATIONS...
And when loading the page, you can simply collect all the notifications for the current user and display them.
This has the advantage of preventing the βever-growing tableβ by only saving entries for current notifications and deleting them when they are no longer needed.
source share