public function csrf($check = false, $force = false)
    {
        if ($this->config['csrf'] !== true) {
            return !empty($check) ? true : '';
        }

        if (session_id() == '' && $this->config['auto_session'] === true) {
            @session_start();
        }

        if ($check === false) {
            $current_token = $this->get_csrf_token();

            if (($current_token !== false && $force) || $current_token === false) {
                $token = sha1(uniqid(microtime(true), true));

                $_SESSION['phery'] = array(
                    'csrf' => $token
                );

                $token = base64_encode($token);
            } else {
                $token = base64_encode($_SESSION['phery']['csrf']);
            }

            return "<meta id=\"csrf-token\" name=\"csrf-token\" content=\"{$token}\" />\n";
        } else {
            if (empty($_SESSION['phery']['csrf'])) {
                return false;
            }

            return $_SESSION['phery']['csrf'] === base64_decode($check, true);
        }
    }
public function csrf($check = false, $force = false)
    {
        if ($this->config['csrf'] !== true) {
            return !empty($check) ? true : '';
        }

        if (session_id() == '' && $this->config['auto_session'] === true) {
            @session_start();
        }

        if ($check === false) {
            $current_token = $this->get_csrf_token();

            if (($current_token !== false && $force) || $current_token === false) {
                $token = sha1(uniqid(microtime(true), true));

                $_SESSION['phery'] = array(
                    'csrf' => $token
                );

                $token = base64_encode($token);
            } else {
                $token = base64_encode($_SESSION['phery']['csrf']);
            }

            return "<meta id=\"csrf-token\" name=\"csrf-token\" content=\"{$token}\" />\n";
        } else {
            if (empty($_SESSION['phery']['csrf'])) {
                return false;
            }

            return $_SESSION['phery']['csrf'] === base64_decode($check, true);
        }
    }
public function csrf ( $ check = false , $ force = false ) { if ( $ this -> config [ 'csrf' ] !== true ) { return ! empty ( $ check ) ? true : '' ; } if ( session_id ( ) == '' && $ this -> config [ 'auto_session' ] === true ) { @ session_start ( ) ; } if ( $ check === false ) { $ current_token = $ this -> get_csrf_token ( ) ; if ( ( $ current_token !== false && $ force ) || $ current_token === false ) { $ token = sha1 ( uniqid ( microtime ( true ) , true ) ) ; $ _SESSION [ 'phery' ] = array ( 'csrf' => $ token ) ; $ token = base64_encode ( $ token ) ; } else { $ token = base64_encode ( $ _SESSION [ 'phery' ] [ 'csrf' ] ) ; } return "<meta id=\"csrf-token\" name=\"csrf-token\" content=\"{$token}\" />\n" ; } else { if ( empty ( $ _SESSION [ 'phery' ] [ 'csrf' ] ) ) { return false ; } return $ _SESSION [ 'phery' ] [ 'csrf' ] === base64_decode ( $ check , true ) ; } }
Output the meta HTML with the token.
This method needs to use sessions through session_start

@param bool $check Check if the current token is valid
@param bool $force It will renew the current hash every call
@return string|bool
Output the meta HTML with the token . This method needs to use sessions through session_start