PHPackages                             rautea/nonce-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. rautea/nonce-php

ActiveLibrary[Security](/categories/security)

rautea/nonce-php
================

Fast PHP nonce and CSRF tokens tool

v1.0.0(1y ago)06MITPHPPHP &gt;=8.1

Since May 30Pushed 1y agoCompare

[ Source](https://github.com/Rautea-Bruno-Paofai/nonce-php)[ Packagist](https://packagist.org/packages/rautea/nonce-php)[ RSS](/packages/rautea-nonce-php/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Nonce PHP
=========

[](#nonce-php)

Fast PHP nonce and CSRF tokens tool, add tokens to your web forms and validate nonces easily using PHP $\_SESSION (or anything else).

Basic Usage
-----------

[](#basic-usage)

First, import and initialize the nonce utility class:

```
// nonce configuration class
$nonceConfig = new \Nonce\Config\Config;

// initialize nonce class
$nonceUtil = new \Nonce\Nonce( $nonceConfig );
```

Then, to create a nonce based on an action name:

```
// make sure you make this call before starting the output or sending HTTP headers
$nonce = $nonceUtil->create( 'signup-form' );
```

Here you see we used the `signup-form` as an action name and we can use that later to verify the nonce supplied to the user request:

Let's use this in our HTML form:

```

    ....
    ....
