package Default

 Methods

Constructor get the current user IP and store it in the session as 'valid data'

__construct(null|string $data = null

Parameters

$data

nullstring

Retrieve token for validating call

getData() : string
inherited_from \Zend\Session\Validator\ValidatorInterface::getData()

Returns

string

Return validator name

getName() : string
inherited_from \Zend\Session\Validator\ValidatorInterface::getName()

Returns

string

Checks proxy handling setting.

getUseProxy() : boolean
Static

Returns

booleanCurrent setting value.

isValid() - this method will determine if the current user IP matches the IP we stored when we initialized this variable.

isValid() : boolean
inherited_from \Zend\Session\Validator\ValidatorInterface::isValid()

Returns

boolean

Set the header to introspect for proxy IPs

setProxyHeader(string $header = 'X-Forwarded-For') : void
Static

Parameters

$header

string

Set list of trusted proxy addresses

setTrustedProxies(array $trustedProxies) : void
Static

Parameters

$trustedProxies

array

Changes proxy handling setting.

setUseProxy(boolean $useProxy = true) : void
Static

This must be static method, since validators are recovered automatically at session read, so this is the only way to switch setting.

Parameters

$useProxy

boolean

Whether to check also proxied IP addresses.

Returns client IP address.

getIpAddress() : string

Returns

stringIP address.

 Properties

 

Internal data.

$data : string

Default

 

HTTP header to introspect for proxies

$proxyHeader : string

Default

'HTTP_X_FORWARDED_FOR'
Static
 

List of trusted proxy IP addresses

$trustedProxies : array

Default

array()
Static
 

Whether to use proxy addresses or not.

$useProxy : boolean

Default

false
Static

As default this setting is disabled - IP address is mostly needed to increase security. HTTP_* are not reliable since can easily be spoofed. It can be enabled just for more flexibility, but if user uses proxy to connect to trusted services it's his/her own risk, only reliable field for IP address is $_SERVER['REMOTE_ADDR'].