I need to display a message to only users with a specific role. The message should appear either as soon as the user logs in or if they re-open their browser after having closed it when logged in to the site.
You can check whether this plugin helps you to achieve your purpose or You can write your own code in your custom plugin with the following approach:
- Check if the user is logged in.
- Check if the current user has the any roles from the specified list of roles which you want the notice to be shown.
- If the above conditions are true just add a Notice to the site.
You might not be needing sessions as you check whether the user is logged in an show the message. If at all you need WordPress Sessions you can use the functions defined in the class WP_Session_Tokens.