Showing posts with label cookies in php. Show all posts
Showing posts with label cookies in php. Show all posts

Tuesday, April 7, 2015

Demonstration of Cookies in PHP



In this article I would like to share with you about a cookie in PHP basically a cookie is a method we use in PHP to identify the user that visited or uses our website. It is a small file the is being send by our server to our user's computer. Every the the user computer send a request to our page with the use of a web browser, it will send a cookie also to the user via a web browser. The code is very simple and easy to understand.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Sample Program Output


Program Listing

<?php
$cookie_name = "visitors";
$cookie_value = "Jake Pomperada";
?>

<html>
<title> Demonstration of Cookies PHP</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>

<body>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Demonstration of Cookies in PHP</h2>
  

<?php
if(isset($_COOKIE[$cookie_name])) {  
$last = $_COOKIE[$cookie_name];  
echo "Welcome back, " . $cookie_value . "! <br>
<br> You last visited this site is ". $last. ".";  
} else {  
echo "Welcome to our website , ". $cookie_value. "!";  
?>

</body>
</div>
</html>