https://secure.php.net/manual/en/function.setcookie.php gives the following example:
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1);
?>
In general, is this the right way to do it, or when looking at good php code in general would you rather/normally see this:
<?php
$value = 'something from somewhere';
$cookie_name = 'TestCookie';
setcookie($cookie_name, $value);
setcookie($cookie_name, $value, time()+3600); /* expire in 1 hour */
setcookie($cookie_name, $value, time()+3600, "/~rasmus/", "example.com", 1);
?>
I know this is an open ended question, but I'm new to php and I want to know why you would do it either way. Or is it pure user preference?