You are here

public function BrowserCookieTrait::setCookie in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/jcalderonzumba/gastonjs/src/Browser/BrowserCookieTrait.php \Zumba\GastonJS\Browser\BrowserCookieTrait::setCookie()

Sets a cookie on the browser, expires times is set in seconds

Parameters

$cookie:

Return value

mixed

File

vendor/jcalderonzumba/gastonjs/src/Browser/BrowserCookieTrait.php, line 31

Class

BrowserCookieTrait
Trait BrowserCookieTrait @package Zumba\GastonJS\Browser

Namespace

Zumba\GastonJS\Browser

Code

public function setCookie($cookie) {

  //TODO: add error control when the cookie array is not valid
  if (isset($cookie["expires"])) {
    $cookie["expires"] = intval($cookie["expires"]) * 1000;
  }
  $cookie['value'] = urlencode($cookie['value']);
  return $this
    ->command('set_cookie', $cookie);
}