Google Ads

Using Cookies in PHP Script


Using Cookies in PHP Script

This is a very simple and basic tutorial in PHP. This will teach you how to use and set cookie in PHP. Cookies allows the webmaster to store user’s or visitor’s information to be accessed on the next visit in the website. It is usually used in logging in, to store the username and password. But note, don’t use cookie on an important information.
Here is the code to set the cookie:

 

 
 
  1. $cookie_name = "visitors";
  2. $cookie_value = "GeePee";
  3. $month = 2592000 + time();
  4. setcookie($cookie_name, date("F jS - g:i A"), $month);

 

And here is the code to retrieve cookie:

 

 
 
  1. if(isset($_COOKIE[$cookie_name])) {
  2.       $last = $_COOKIE[$cookie_name];
  3.       echo "Welcome back, " . $cookie_value . "! <br> You last visited on ". $last. ".";
  4. } else {
  5.       echo "Welcome to our site, ". $cookie_value. "!";
  6. }

 

 

 


Related Post

Expert System For Identifying Kind Of Gaharu PHP S... Expert System For Identifying Kind Of Gaharu PHP Script It is a expert system program for identifying kind of Gaharu, using method Forward Ch...
Simple Hotel Customer Information Admin Using Code... Simple Hotel Customer Information Admin Using CodeIgniter PHP Script This is a simple Customer Information Admin page where you can add new custome...
WhizClassified v1.7 – Classifieds CMS PHP Sc... WhizClassified v1.7 - Classifieds CMSWhizClassified v1.7 - Classifieds CMSWhizClassified : Complete and easily manageable Classifieds CMSDemo: http://...
Magic Hover – JavaScript Plugin PHP Script D... Magic Hover - JavaScript PluginMagic Hover - JavaScript PluginThis plugin allows you to add layesr with different effects to images, that appear when ...
phpFreeChat v2.0.2 Debug PHP Script Download phpFreeChat v2.0.2 Debug PHP Script Download phpFreeChat is a free, simple to install, fast, customizable and multi languages chat that uses a simp...

Have any Question or Comment?

Leave a Reply

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

"