php set cookie
snippet in php

setcookie php

user5962

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

make cookies pph

user9315

setcookie("cookiename", "cookievalue", time(), ".mydomain.tld", "/")

// coookiename: The name of your cookie
// cookievalue: The value of your cookie
// Time: The expiration date of your cookie. If you plan to make a product for the EU, it's 13 months max.
// .mydomain.tld: The domain that your webpage is using. You can only use the domain that the PHP file is on. Adding a dot before your domain will cover all subdomains.
// "/": This is the folder where your cookie will apply. If you want a specific cookie for the /mySpecialSuperSecretPages folder, you have to set /mySpecialSuperSecretPages
// Check the source for more options.

php set cookie

user8727

setcookie(name, value, expire, path, domain, secure, httponly);
// Only the name parameter is required.
// Must appear BEFORE the <html> tag.
// Saved in $_COOKIE[name]

cookies php syntax

user2893

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

cookie are not set in php

user9745

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

php set cookie

user4638

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