Application::useTicket
Check a one-time ticket and use it up
Description
public bool Application::useTicket( string $name )
Check the ticket issued by Application::setTicket. Returns true only when the POST parameter ticket_{$name} has the same value as the ticket in the session. The ticket is then removed from the session, so a second submit of the same form returns false.
The ticket is read from POST only.
Arguments
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $name | string | Ticket name |
Example
Controller
public function result()
{
if (!$this->useTicket('contact')) {
// Reloaded, submitted twice, or not posted from the form
$this->redirect('/contact/');
}
// send the mail ...
$this->displayPage('contact/result');
}