Loading...
PHP

Cookie

Cookie is some text information in client system used to maintain the state of application the data of cookie we can access from any location in the server. Cookie is divided into two types.
1. in memory cookie
2. persistent cookie

  1. in memory cookie: 
    A cookie without any explicit time is called as in memory cookie. This cookie stores the information in ram memory location and destroys the data when closed the browser.
  2. persistent cookie:
    Cookie with explicit expiry time is called as persistent cookie. This cookie stores information in hard disc and release the data when life time is completed.

Set Cookie: By using this function we can create cookie is in client system, arguments are cookie name, value and expiry time.

$_COOKIE:  By using this Super Global Variable we can read the value of cookie
Example”
<?php
set cookie(“x”,100);
echo $_COOKIE[‘x];
?>
<a href= “page2.php”>Goa </a>
page2.php
<?php
echo “Hi”;
echo $_COOKIE[‘x’];
echo”Welcome”;
?>

Leave a Reply

Your email address will not be published. Required fields are marked *