X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Frequest%2Fclass_HttpRequest.php;fp=inc%2Fclasses%2Fmain%2Frequest%2Fclass_HttpRequest.php;h=b6f9b95f46c6f2cd874228c1b2afde5532df8f1c;hb=b848cab53db89342f0a854a00be91cadbcff2967;hp=e3bb312f9ea3757b0cb0d4dbd7b70a187a567c30;hpb=425cd4dda06724de295f7762c27efc2e539c2a53;p=shipsimu.git diff --git a/inc/classes/main/request/class_HttpRequest.php b/inc/classes/main/request/class_HttpRequest.php index e3bb312..b6f9b95 100644 --- a/inc/classes/main/request/class_HttpRequest.php +++ b/inc/classes/main/request/class_HttpRequest.php @@ -93,7 +93,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { if (!isset($this->requestData[$element])) { // Then throw an exception throw new MissingArrayElementsException(array($this, 'requestData', $element), self::EXCEPTION_MISSING_ELEMENT); - } + } // END - if // All clear return true; @@ -113,7 +113,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { try { if ($this->isRequestElementSet($element)) { $value = $this->requestData[$element]; - } + } // END - if } catch (MissingArrayElementsException $e) { // Do nothing here } @@ -158,7 +158,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { // Does this header exist? if (isset($_SERVER[$name])) { $headerValue = $_SERVER[$name]; - } + } // END - if // Return the value return $headerValue; @@ -176,7 +176,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { /** * Sets wether the request was valid (default: true) * - * @param $isValid Wether the request is valid + * @param $isValid Wether the request is valid * @return void */ public final function requestIsValid ($isValid = true) { @@ -191,6 +191,26 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { public final function isRequestValid () { return $this->requestIsValid; } + + /** + * Reads a cookie and returns it's value or null if not found + * + * @param $cookieName Name of cookie we shall read + * @return $cookieValue Value of cookie or null if not found + */ + public final function readCookie ($cookieName) { + // Default is no cookie with that name found + $cookieValue = null; + + // Is the cookie set? + if (isset($_COOKIE[$cookieName])) { + // Then get it + $cookieValue = $_COOKIE[$cookieName]; + } // END - if + + // Return the value + return $cookieValue; + } } // [EOF]