XF 2.2 Recognize a visitor (guest or logged in) via a hash

Scandal

Well-known member
I'm looking for a variable (maybe a hash like md5), accessable via the \XF::app()-> or \XF::visitor()-> / or/ and something like session to use it.
I need this hash to be static based on IP and User Agent and so on for guests and logged in users.

For example, I could add this on User Entity:
PHP:
    public function getVisitorHash()
    {
        $ipAddress = \XF::app()->request->getIp();
      
        // with some salt
        return md5($ipAddress . $_SERVER['HTTP_USER_AGENT'] . '545437523970243');
    }
... but I guess xenForo 2 has already a way to return something similar.

Any idea? :)
 
Last edited:
Top