Session:

Session is a way to store data or information in the form of variable, which can be use across multiple pages or across the whole project. Unlike cookie, session store data on server site.
Before defining session variable it must be start on the top of the page or in header.
It can be start like this
<?php Session_start() ?>
After start variable can be define as.

<?php $_SESSION[‘data’]= ‘session value’; ?>

And if you want to print the session value then it could be written as
<?php echo “SESSION VALUE=”.$_SESSION[‘data’]; ?>

Cookie:

Cookie also known as web cookie or browser cookie is a small piece of data sent from a website and stored in a user web browser while the user is browsing the website. The main purpose of cookie is to store all activity of the user over that website(e,g history, usename and password etc).
We can set the cookie value and expiry time using the below php code
<?php
$expire =             time()+60*60*24*15  // expiry date set to 15 days
Setcookie(“name”,”something”,$expire);
?>
If you want to echo the cookie data then it will be

<?php echo $_COOKIE[‘name’]?>