trait BrowserCookieTrait in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/jcalderonzumba/gastonjs/src/Browser/BrowserCookieTrait.php \Zumba\GastonJS\Browser\BrowserCookieTrait
Trait BrowserCookieTrait @package Zumba\GastonJS\Browser
Hierarchy
- trait \Zumba\GastonJS\Browser\BrowserCookieTrait
File
- vendor/
jcalderonzumba/ gastonjs/ src/ Browser/ BrowserCookieTrait.php, line 11
Namespace
Zumba\GastonJS\BrowserView source
trait BrowserCookieTrait {
/**
* Gets the cookies on the browser
*
* @return Cookie[]
*/
public function cookies() {
$cookies = $this
->command('cookies');
$objCookies = array();
foreach ($cookies as $cookie) {
$objCookies[$cookie["name"]] = new Cookie($cookie);
}
return $objCookies;
}
/**
* Sets a cookie on the browser, expires times is set in seconds
* @param $cookie
* @return mixed
*/
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);
}
/**
* Deletes a cookie on the browser if exists
* @param $cookieName
* @return bool
*/
public function removeCookie($cookieName) {
return $this
->command('remove_cookie', $cookieName);
}
/**
* Clear all the cookies
* @return bool
*/
public function clearCookies() {
return $this
->command('clear_cookies');
}
/**
* Enables or disables the cookies con phantomjs
* @param bool $enabled
* @return bool
*/
public function cookiesEnabled($enabled = true) {
return $this
->command('cookies_enabled', $enabled);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BrowserCookieTrait:: |
public | function | Clear all the cookies | |
BrowserCookieTrait:: |
public | function | Gets the cookies on the browser | |
BrowserCookieTrait:: |
public | function | Enables or disables the cookies con phantomjs | |
BrowserCookieTrait:: |
public | function | Deletes a cookie on the browser if exists | |
BrowserCookieTrait:: |
public | function | Sets a cookie on the browser, expires times is set in seconds |