Set Cookies Get Cookies Delete Cookies with PHP
In this Post We Will Explain About is Set Cookies Get Cookies Delete Cookies with PHP With Example and Demo.
Welcome on Pakainfo.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to Create, Read, Update and Delete a Cookie with PHP
In this post we will show you Best way to implement Login, Logout and Administrate using PHP SESSION, COOKIE & MySQL, hear for How to How to get set and delete cookies in PHP with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
What is Cookies?
A cookie is some often used to uniq identify a user. A cookie is a simple and easy to small file that the based on the server embeds on the All the visit user’s computer. as well as Each time the same like as a computer requests browesr side a page with a simple browser, it will simple send the some cookie too. With PHP used to cookie, we can both simple create and retrieve any type cookie values as well as delete cookie using PHP.
Uses of cookies
Steps Cookies can be used for various some purpose such as:
First of all to store information like to Store user preferences like as a (color name, differnt font size, differnt element size, differnt theme etc.)
and then second Track progress (like as page number or percentage, etc.)
here some Store username to visit any sites or numbers (to set to identify user)
Set Cookie
Syntext of the Set Cookies Get Cookies Delete Cookies with PHP
setcookie(NAME, VALUE, EXPIRE, PATH, DOMAIN, SECURE, HTTPONLY)
Example of the How to Create, Access and Delete Cookies in PHP
$liveCooki_val = 'Chrome'; //variable setcookie("browser", $liveCooki_val, time()+3600); //yout cookie name, value as well as time (1 hour) or $liveCooki_val = 'Chrome'; // simple variable setcookie("browser", $liveCooki_val, time()+3600, '/', 'Pakainfo.com', true, true);
Retrieve Cookie Value
echo 'Pakainfo.com - >Your simple browser is ' . $_COOKIE['browser'];
Example of the How to Create, Read, Update and Delete a Cookie with PHP
if(isset($_COOKIE['browser'])) //conditios check cookie exist { echo 'simple Your browser is ' . $_COOKIE['browser']; }
Or a shorthand way :
$cookie_value = (isset($_COOKIE['browser']))? $_COOKIE['browser'] :'no cookie'; echo $cookie_value ;
Delete a Cookie
Example of the How to delete cookies in PHPHow to delete cookies in PHP
setcookie("browser", "", time()-3600); //here specific expiration time set all to one hour ago
I hope you have Got Understanding Session and Cookies Variables Concept in PHP And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.