What are the difference between session and cookies in PHP?
Session and Cookies both functions are used to store information. But the main difference between a session and a cookie is that in case of session data is stored on the server but cookies stored data on the browsers.
Sessions are more secure than cookies because session stored information on servers. We can also turn off Cookies from the browser.
$_SESSION['user'] = 'BestInterviewQuestion.com';
//destroyed the entire sessions
//Destroyed the session variable "user".
Example of Cookies
setcookie(name, value, expire, path,domain, secure, httponly);
$cookie_uame = "user";
$cookie_uvalue= "Umesh Singh";
//set cookies for 1 hour time
setcookie($cookie_uname, $cookie_uvalue, 3600, "/");