public function saveLayout()
    {
        $this->checkTokenInUrl();

        $layout      = Common::unsanitizeInputValue(Common::getRequestVar('layout'));
        $layout      = strip_tags($layout);
        $idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
        $name        = Common::getRequestVar('name', '', 'string');

        if (Piwik::isUserIsAnonymous()) {
            $session = new SessionNamespace("Dashboard");
            $session->dashboardLayout = $layout;
            $session->setExpirationSeconds(1800);
        } else {
            $this->getModel()->createOrUpdateDashboard(Piwik::getCurrentUserLogin(), $idDashboard, $layout);
            if (!empty($name)) {
                $this->getModel()->updateDashboardName(Piwik::getCurrentUserLogin(), $idDashboard, $name);
            }
        }
    }