Here is a simple code that explains how a cookie is set and retrieved using php.
A cookie is set with the following code: setcookie(name, value, expiration)
$Month = 2592000 + time();
//this adds 30 days to the current time
setcookie(MyVisit, date(“F jS – g:i a”), $Month);
?>
The above code sets a cookie named “MyVisit” in the visitors browser. The cookie sets the value to the current date, and set’s the expiration to be be in 30 days (2592000 = 60 seconds * 60 mins * 24 hours * 30 days.)
Now as the cookie is set, we have to retrieve this cookie in another page so for that copy this code
Now let’s retrieve the cookie.
<?php
if(isset($_COOKIE['MyVisit']))
{
$last = $_COOKIE['MyVisit'];
echo “Welcome back! <br> You last visited on “. $last;
}
else
{
echo “Welcome to our site!”;
}
?>
Simple try out this code and enjoy!!!!!!!!!!!
Incoming search terms:
- Spreadsheet_Excel_Writer AutoFilter (2)
- inurl:”?module=guestbook” (2)
- disable textbox cookies using jquery (1)
- symfony search result pagination (1)
- shell script automark (1)
- set cookie using htaccess (1)
- PHP cookie browser close (1)
- jquery autocomplete in php for dynamictextbox (1)
- if cookies is set show the div in php (1)
- get cookie using php (1)
- textbox onchange mysql with demo (1)
You will also be interested in ,
- Close Event In Javascript For Firefox, IE and Chrome
- Learn CSS Basics Very Simple Tutorial
- Single and Multiple selection listbox
- Pass PHP Value To Javascript
- Adding and removing child nodes using javascript and DOM
- Change background color using php for a webpage
- Text auto slide information box using javascript.
- Enter only numbers inside a input field of a form using javascript
- Add to favorites or bookmarking using javascript in firefox and internet explore [IE]
- Water mark images using PHP 5 and GD Library

