What are the advantages and disadvantages of using cookies instead of IP addresses for tracking likes in PHP?
Using cookies instead of IP addresses for tracking likes in PHP can provide more accurate tracking as cookies are specific to individual users rather than devices. This means that if a user changes their device or IP address, their like history will still be maintained. However, using cookies also comes with the disadvantage of users being able to easily delete or block cookies, potentially affecting the accuracy of the tracking.
```php
// Set a cookie to track likes
$like_id = 123;
setcookie('like_'.$like_id, '1', time() + (86400 * 30), '/');
```
Note: This code sets a cookie named 'like_123' with a value of '1' that expires in 30 days. You can modify the code to suit your specific tracking needs.