How to store IP addresses into database table, who are visited my site recently?

how to run the code dynamically without calling explicitly to store into database table those who are the recently visited user’s/guest’s IP addresses of my site…

Give me the ideas/example to do it…

Thanking you…

Do you want to log the IP address of all users? Are you storing sessions in a database?

You could set your code to log the IP used when a new session is created, be aware that a user’s IP address may change during their session.