ParagonIE\AntiCSRF\AntiCSRF::generateToken PHP Method

generateToken() protected method

Generate, store, and return the index and token
protected generateToken ( string $lockTo ) : array
$lockTo string What URI endpoint this is valid for
return array
    protected function generateToken(string $lockTo) : array
    {
        $index = Base64::encode(\random_bytes(18));
        $token = Base64::encode(\random_bytes(33));
        $this->session[$this->sessionIndex][$index] = ['created' => \intval(\date('YmdHis')), 'uri' => isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : $this->server['SCRIPT_NAME'], 'token' => $token];
        if (\preg_match('#/$#', $lockTo)) {
            $lockTo = Binary::safeSubstr($lockTo, 0, Binary::safeStrlen($lockTo) - 1);
        }
        $this->session[$this->sessionIndex][$index]['lockTo'] = $lockTo;
        $this->recycleTokens();
        return [$index, $token];
    }