What is the difference between session and cookie

Learn the difference between sessions and cookies in web development. Sessions store user data on the server side, while cookies store data in the user’s browser.

session, cookie, web development, user data storage, server-side storage, browser storage

// Example of using session in PHP session_start(); // Start the session $_SESSION['username'] = 'JohnDoe'; // Set session variable // Example of using cookie in PHP setcookie('username', 'JohnDoe', time() + 3600); // Set cookie to expire in 1 hour

session cookie web development user data storage server-side storage browser storage