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
string
The property name
__set(string $name,string $value): void
string
The property name
string
The 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. |
---|---|
string
The name of the cookie we want to delete
string
Define 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 |
---|---|
string
the name of the cookie we want to get
getCurrentUrl(): string
string
A 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 |
---|---|
string
the 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 |
---|---|
string
the name for the cookie we want to create
string
the value we want to set to the new cookie.
mixed
The 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.
string
Define 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.
string
Define the domain where the cookie is valid. Default: domain of page where the cookie was created.
boolean
If true, the cookie transmission requires a secure protocol (https). Default: false.