I refactored the code and found something that I had never seen. The function is used to set a cookie by the user when the user logs in:
function setUserCookie($name, $value) { $date = date("D, d MYH:i:s",strtotime('1 January 2015')) . 'GMT'; header("Set-Cookie: {$name}={$value}; EXPIRES{$date};"); }
now that I have the refactoring code assigned to me, I plan to use the setcookie function, which essentially does the same thing according to php.net.
My question is: is there a difference between the two and which one should I use?
NOTE: this code was written many years ago, so I assume that setcookie did not exist at that time?
Ggio
source share