Skip to content

Latest commit

 

History

History
164 lines (96 loc) · 2.64 KB

Token.md

File metadata and controls

164 lines (96 loc) · 2.64 KB

Token

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

Token::getName

Description

public getName (void)

Get tracking token name

Parameters

This function has no parameters.

Return Values

string|null


Token::setName

Description

public setName (string $name)

Set tracking token name

Parameters

  • (string) $name

Return Values

self


Token::getValue

Description

public getValue (void)

Get tracking token value

Parameters

This function has no parameters.

Return Values

string|null


Token::generate

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


Token::setValue

Description

public setValue (string $value)

Set tracking token value

Parameters

  • (string) $value

Return Values

self


Token::setCookie

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


Token::removeCookie

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