What are the differences between storing values in cookies versus sessions in PHP?

Storing values in cookies means that the data is stored on the client's side, while storing values in sessions means that the data is stored on the server side. Cookies have a limited storage capacity and are less secure as they can be manipulated by the client. Sessions are more secure as the data is stored on the server and are not accessible by the client.

// Storing a value in a cookie
setcookie("user_id", "12345", time() + 3600, "/");

// Storing a value in a session
session_start();
$_SESSION["user_id"] = "12345";