How to set Cookie Using PHP
Today we will check how set cookie in php.cookie is stored in client side, not on server side.We will temporary store value using cookie for our functions.Its very easy to set cookie in php.
<?php //setting a cookie $country = "India"; $expiry_period = time() + (86400 * 7)); // 86400 = 1 day setcookie('country',$country,$expiry_period); ?>
Now your cookie is set ,you will get the value of this cookie by using variable $_cookie.
<?php //getting a cookie $country_value = $_COOKIE['country']; ?>
Hope this will help you.