![]() |
Post Visit CounterWith Ip - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Post Visit CounterWith Ip (/showthread.php?tid=78419) |
Post Visit CounterWith Ip - thedragon655 - 01-17-2021 does anyone knows how to implement an IP based view counter when someone clicks my posts? how do we make this in ci4 thank you RE: Post Visit CounterWith Ip - InsiteFX - 01-18-2021 1) Create a database page_visits table. 2) Use CodeIgniters incoming request class to get the users IP address. 3) Check database to see if the IP exists. 4) If the IP exists then increment counter and save to database RE: Post Visit CounterWith Ip - AndresHDZ - 01-18-2021 Something like this: PHP Code: $ipTableModel = new App\Models\IpTableModel(); RE: Post Visit CounterWith Ip - thedragon655 - 01-19-2021 will try this out does the model returntype have to be an array? thanks RE: Post Visit CounterWith Ip - AndresHDZ - 01-19-2021 (01-19-2021, 07:29 AM)thedragon655 Wrote: will try this out does the model returntype have to be an array? thanks I like to work with objects, but I think you wont have any problem using array. RE: Post Visit CounterWith Ip - paliz - 01-19-2021 (01-17-2021, 03:44 PM)thedragon655 Wrote: does anyone knows how to implement an IP based view counter when someone clicks my posts? how do we make this in ci4 thank youthe code needs get user location use _helper ci4 then call funtion in controller all you need PHP Code: function getCountryByIp($ip) |