PHP code example of phpgt / cookie
1. Go to this page and download the library: Download phpgt/cookie library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpgt / cookie example snippets
// Create a replacement for $_COOKIE.
$cookie = new Gt\Cookie\CookieHandler($_COOKIE);
// Access values as normal.
$value = $cookie["firstVisit"];
if(isset($cookie["firstVisit"])) {
// Cookie "firstVisit" exists.
}
if($cookie->has("firstVisit")) {
// Cookie "firstVisit" exists.
}
else {
// Create a new cookie that expires in ten days.
$now = new DateTime();
$expire = new DateTime("+10 days");
$cookie->set("firstVisit", $now, $expire);
}
// Now you can unset the superglobal!