An abstraction of the browser entity an all its related operations and properties Browser entity is normally available only on client side or front end view applications, but some of its features can also make sense on a server side app. So depending on the implementation language, this class may or may not have some of its methods implemented.
| package | Default |
|---|
__get(string $name): void
stringThe property name
__set(string $name,string $value): void
stringThe property name
stringThe property value
deleteCookie(string $key,string $path = '/')
| returns | boolean True if cookie was deleted or false if cookie could not be deleted or was not found. |
|---|---|
stringThe name of the cookie we want to delete
stringDefine the path where the cookie is set. By default it is the whole domain: '/'. If the cookie is not set on this path, we must pass the right one or the delete will fail.
getCookie(string $key)
| returns | string Cookie value or null if cookie does not exist |
|---|---|
stringthe name of the cookie we want to get
getCurrentUrl(): string
stringA well formed url
getCurrentUrlQueryValues()
getPreferredLanguage()
NOTE: Getting browser language is not accurate. It is always better to use server side language detection
| returns | A two digits string containing the detected browser language. For example 'es', 'en', ... |
|---|---|
isCookie(string $key)
| returns | boolean True if cookie with specified name exists, false otherwise |
|---|---|
stringthe name for the cookie we want to find
isCurrentUrlWithQuery()
setCookie(string $key,string $value,mixed $expires = '',string $path = "/",string $domain = '',boolean $secure = false)
Adapted from the jquery.cookie plugin by Klaus Hartl: https://github.com/carhartl/jquery-cookie
| returns | boolean True if cookie was created, false otherwise. An exception may be thrown if invalid parameters are specified |
|---|---|
stringthe name for the cookie we want to create
stringthe value we want to set to the new cookie.
mixedThe lifetime of the cookie. Value can be a Number which will be interpreted as days from time of creation or a Date object. If omitted or '' string, the cookie becomes a session cookie.
stringDefine the path where the cookie is valid. By default it is the whole domain: '/'. A specific path can be passed (/ca/Home/) or a '' string to set it as the current site http path.
stringDefine the domain where the cookie is valid. Default: domain of page where the cookie was created.
booleanIf true, the cookie transmission requires a secure protocol (https). Default: false.