Best method to show modal only once

There is no best practice here, and to be really honest, cookies are your best (and probably only) option here.

The issue with visitors are that they are only visitors. If they were first time signup members and you would want to show something to them only once when they are done registering, the best option would be to save an unique value as user meta in the db under that specific member. You can then simply check for that value and hide the content if the value exist.

There is just no use in capturing a visitor’s IP, saving it in db and having to check and save values for each and every visitor. You are going to have tons of useless data in the db.

Yes, cookies are not reliable at all due to many factors like incognito windows, cleaning browser caches or disabled cookies in a browser, etc etc. There are also laws regarding the use of cookies which you should also consider.

At the end of the day you would need to do what is best for you here, if you need reliability, you would log the visitors IP in db and match IP’s for all non logged in users, if reliability is not an issue, cookies would do. Just remember, IP’s are not unique to a specific visitor. 100 people can visit your site from the same IP (computer) in an internet cafee