Last updated on May 11th, 2016 at 02:07 pm

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

PHP Code To Set And Retrieve Cookie

I am going to create a cookie named userSetting a cookie using PHP
In the code below cookie is set to after expire 30 days [60*60*24*30] from the day it got created.

<?php
$expire=time()+60*60*24*30;
setcookie("user","John", $expire);
?>

Retrieve a cookie using php

<?php
if (isset($_COOKIE["user"]))
echo "Welcome " . $_COOKIE["user"] . "!<br />";
else
echo "Welcome guest!<br />";
?>

Very simple is it….enjoy!!!!!!!!!!!!!!

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Leave a Reply

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