This class is in charge of managing and generating unique tokens to associate with your visitors, including methods for setting and removing their tracking cookies.
Name | Description |
---|---|
getName | Get tracking token name |
setName | Set tracking token name |
getValue | Get tracking token value |
setValue | Set tracking token value |
generate | Set the token value to a new generated hash |
setCookie | Set tracking cookie with the token name and value |
removeCookie | Remove tracking cookie |
Description
public getName (void)
Get tracking token name
Parameters
This function has no parameters.
Return Values
string|null
Description
public setName (string $name)
Set tracking token name
Parameters
(string) $name
Return Values
self
Description
public getValue (void)
Get tracking token value
Parameters
This function has no parameters.
Return Values
string|null
Description
public generate (mixed $id)
Set the token value to a new generated hash
Use $id
to generate a static hash that will always be the same given the current token name and identifier
This is useful for creating a token based on e.g. a user ID
If no identifier is passed, a unique hash is randomly generated
Parameters
(mixed) $id
: Unique identifier (e.g. a user ID)
Return Values
self
Description
public setValue (string $value)
Set tracking token value
Parameters
(string) $value
Return Values
self
Description
public setCookie (string|null $value, int|string|null $expires)
Set tracking cookie with the token name and value
This sends a cookie to the users browser with the configured settings (and if passed, a custom value and expires timestamp)
Parameters
(string|null) $value
: Defaults to configured value(int|string|null) $expires
: Defaults to current time plus configured max age
Return Values
self
Description
public removeCookie (void)
Remove tracking cookie
This sends a cookie to the users browser with the configured settings, but with false as value, and an expiration date set to a time in the past, removing the cookie
Parameters
This function has no parameters.
Return Values
self