php cookie set code example

Example 1: setcookie php

setcookie($cookiename, $cookievalue, time() + (86400 * 30), "/"); // 86400 = 1 day

Example 2: cookie are not set in php

setcookie('username',$username,time()+60*60*24*365);
// 'Force' the cookie to exists
$_COOKIE['username'] = $username;

Example 3: php set cookie

<?php
  $name = 'COOKIE_NAME';
  $value = 'VALUE';
  $expireTime = strtotime('+1 years');
  $path = '/';
  setcookie($name,$value,$expireTime,$path);

Example 4: php cookie

setcookie ('name', 'value', $expiresOn, $path, $domain, $secure, $httponly)

Example 5: cookies php syntax

setcookie("cookie_name", "type_on_cookie", expiry_time(), "/");

Tags:

Php Example