What is the difference between using sessions and cookies for storing user data in PHP?
Sessions store user data on the server side, while cookies store data on the client side. Sessions are more secure as the data is not exposed to the user, while cookies can be tampered with by the user. Using sessions is recommended for storing sensitive user data.
// Using sessions to store user data
session_start();
$_SESSION['username'] = 'JohnDoe';
$_SESSION['email'] = 'johndoe@example.com';