Cookie In PHP
Cookie Scenario : A user requests a secure search in the browser, and for that, the search function checks whether the user is has logged in or not. If yes, it proceeds else it will ask the user to login by displaying a login form.
In this scenario, the search function searches for a text file in browser which stores the user credentials. If valid/existing data is found then it redirects further.
This encrypted text file is named as Cookie which is stored on a user's computer in browser's directories. They are designed to hold a modest amount of data specific to a particular client and website.
Why to use cookie?
Setting cookie
#Syntax setcookie (name, value, expires); #Example setcookie("Name", "Prateek", time()+3600);
Retrieving cookie
#Syntax $_COOKIE['name'] #Example echo 'Welcome '.$_COOKIE['EName'];