Function __global->cms_setcookie

Definitions

sources/global3.php

  • Create (or expire) a cookie, inside the software's cookie environment.
  • 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 of the cookie
$value string No No required parameter N/A N/A The value to store in the cookie (blank: delete the cookie)
$session boolean No No False N/A N/A Whether it is a session cookie (gets removed once the browser window closes)
$httponly boolean No No True N/A N/A Whether the cookie should not be readable by JavaScript
$days ?float No No Null N/A N/A Days to store; not applicable for session cookies unless expiring it (null: default) (-14: expire the cookie)

Returns

  • The result of the PHP setcookie command
  • Type: boolean
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Create (or expire) a cookie, inside the software's cookie environment.
 *
 * @param  string $name The name of the cookie
 * @param  string $value The value to store in the cookie (blank: delete the cookie)
 * @param  boolean $session Whether it is a session cookie (gets removed once the browser window closes)
 * @param  boolean $httponly Whether the cookie should not be readable by JavaScript
 * @param  ?float $days Days to store; not applicable for session cookies unless expiring it (null: default) (-14: expire the cookie)
 * @return boolean The result of the PHP setcookie command
 */

function cms_setcookie(string $name, string $value, bool $session = false, bool $httponly = true, ?float $days = null) : bool