You can delete the cookie by setting expiration date in the past
Example:
<?php
setcookie(“user”, “”, time()-3600);
?>
You can delete the cookie by setting expiration date in the past
Example:
<?php
setcookie(“user”, “”, time()-3600);
?>
// Display cookie value
<?php
echo $_COOKIE[“user_name”];
?>
You can view all cookies as follows
<?php
print_r($_COOKIE);
?>
Cookies can be created using the function ‘ setcookie(name,Value ,exp,path,domain)’ and its arguments are given below
Name :Name of the cookie that store the value and it is using to retrieve the stored data
Value : Its the value to be stored in the cookie ()generally we store login details like username , password)
exp : This is the the time that cookie lasts . if its not set ,the cookie will get destroyed when the browser closed .
path : This is path where the cookie to be stored
Domain: Domain where the cookie to be generated
Example
======
<?php
setcookie(“user_name”, “phpcodez”, time()+3600);
?>
Cookies can be used to store user information for future use . Cookies allow us to store data in users’ machine it self . Cookie is a small file that the server generate in user machine and using that file server can identify the user .When ever the browser send http request to the server , it send the cookies as well . Cookies can be created using PHP functions .
Also called a permanent cookie, or a stored cookie, a cookie that is stored on a user s hard drive until it expires (persistent cookies are set with expiration dates) or until the user deletes the cookie.
Persistent cookies help websites remember your information and settings when you visit them in the future. This result in faster and more convenient access since, for example, you don’t have to login again.
Besides authentication, other website features made possible by persistent cookies include: language selection, theme selection, menu preferences, internal site bookmarks or favorites, among many others. On your first visit, the website is presented in default mode. During your visit, you select your preferences and these preferences are remembered, through the use of the persistent cookie, the next time you visit the site.