function Present() { //only update the csrf token on the session when outputting the field. $this->Token = jf::$Security->RandomToken(); jf::SaveSessionSetting(jFormCsrf::SettingNamePrefix . $this->Name(), $this->Token); echo "<input class='jWidget jFormCSRF' type='hidden' name='{$this->Name()}' value='{$this->Token}' />\n"; }
/** * Generates the token for this instance. If already generated, removes and makes another, * so it should be called inside dumpImage */ function Generate() { $settingName = jFormCaptcha::SettingNamePrefix . $this->Name(); // $list="abcdefghijkmnopqrstuvwxyz"; $list = "ABDEHJKMNOPQRSTUWXYZ"; $text = ""; for ($j = 0; $j < 5; ++$j) { $text .= $list[jf::rand(0, strlen($list) - 1)]; } $this->Token = $text; jf::SaveSessionSetting($settingName, $this->Token, \jf\Timeout::MINUTE * 15); return $text; }
/** * Store some data in the session * * @param string|int $key The key associated with the value * @param mixed $value The actual value to be stored * * @throws ArgumentMissingException If $key or $value is missing */ protected function saveSessionData($key = null, $value = null) { if ($key == null || $value == null) { throw new ArgumentMissingException('Missing key/value for saving session data'); } \jf::SaveSessionSetting($key, $value); }
/** * @depends testSaveSession */ function testDeleteSession() { jf::SaveSessionSetting("some_name", "some_value"); $this->assertTrue(jf::DeleteSessionSetting("some_name")); }