Add a mature content warning to first-time visitors

This might not answer your question directly, but there are a few big issues you have to address here. Adult sites get a lot of traffic (usually a lot of fake, hacker and spam traffic), which means a lot of wasted space in your db and slower loading times if you are going to make use of ip addresses to save a first time visit.

Think about it, if recieved 100 000 unique hits, you will have 100 000 ip addresses saved. This translates to 100 000 ip addresses that needs to be checked on every page load. With already slow serving times due to large adult material being loaded, this will only frustate the end user

Cookies does seem to be a better idea, although some countries have very strict regulations about cookies and adult material. This is frankly something that you will need to research yourself and make sure your site is compliant with all regulations

I really don’t think there is any real solution to this problem, yes, saving ip addresses might be the safest, but it is the slowest.

A possible solution might be to make use of a static frontpage which serves as a notice and warning page. You then make use of referrers to check from where a specific page was referred from (not 100% reliable). If a page was referred from any page outside the site or it was directly accessed or there is no referrer, redirect the user to the static front page. You can then set a custom query_vars in all your links that will serves as a reliable internal referrer.

On every page load you then just simply check if the specific query_vars is set in the url, and if it is, load the specific page.

This is just one option to explore and definitely need much more planning and a lot of testing to find the best option