def custom_admin_notification(session, notification_type, message, task_id=None):
    """
    Function for implementing custom admin notifications.
    notifications are stored in session and show to user when user refreshes page.

    A valid session object must be passed to this function with notification type and message
    
    Type of notifications:
        * success
        * info
        * warning
        * error

    message is able to parse html so we can use html tags and classes while creating message
    """
    notification = {"type": notification_type, "message": message}
    messages = []

    if task_id:
        notification["task_id"] = task_id

    if "notifications" in session:
        messages = session['notifications']
    messages.append(notification)
    session['notifications'] = messages
    return session