Simple Cookie script in PHP

Simple cookie script in PHP. Set cookie and get cookie. This is a great way of storing user prefferences, settings and customizations on the site.

<?php// SET COOKIE

setcookie("cookieName1", "cookieValue", time()+60*60*24*30 );
// or do it this way
setcookie($cookieName2, $cookieValue, time()+60*60*24*30 );

// GET COOKIE

$cookie1 = $_COOKIE['cookieName1'];
$cookie2 = $_COOKIE['cookieName2'];

?>

If you liked this post, share it with your friends!

Please Leave Your Comment

Please make sure to enter the required information where indicated. We moderate all comments so please no link dropping; do not spam, and do not advertise!
 

Name (required):

Email (will not be published) (required):

Website:

Comment: