Function __global->setcookie

Definitions

sources_custom/phpstub.php

  • Send a cookie.TODO: Should remove this and prefer cms_setcookie for GDPR compliance.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: bool

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$name string No No required parameter N/A N/A The name
$value ?string No No Null N/A N/A The value (null: unset existing cookie)
$expire integer No No 0 N/A N/A Expiration timestamp (0: session cookie)
$path ?string No No Null N/A N/A Path (null: current URL path)
$domain ?string No No Null N/A N/A Domain (null: current URL domain)
$secure boolean No No False N/A N/A Whether the cookie is only for HTTPS
$httponly boolean No No False N/A N/A Whether the cookie will not be available to JavaScript

Returns

  • Success status (fails if output already started) (null: failed also)
  • Type: ?boolean
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Send a cookie.TODO: Should remove this and prefer cms_setcookie for GDPR compliance.
 *
 * @param  string $name The name
 * @param  ?string $value The value (null: unset existing cookie)
 * @param  integer $expire Expiration timestamp (0: session cookie)
 * @param  ?string $path Path (null: current URL path)
 * @param  ?string $domain Domain (null: current URL domain)
 * @param  boolean $secure Whether the cookie is only for HTTPS
 * @param  boolean $httponly Whether the cookie will not be available to JavaScript
 * @return ?boolean Success status (fails if output already started) (null: failed also)
 */

function setcookie(string $name, ?string $value = null, int $expire = 0, ?string $path = null, ?string $domain = null, bool $secure = false, bool $httponly = false) : ?bool