PHPackages                             jimmiw/csrf - 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. jimmiw/csrf

ActiveLibrary

jimmiw/csrf
===========

Handle CSRF tokens in vanilla systems

2.0.0(2y ago)0102MITPHPPHP &gt;= 7.0

Since May 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jimmiw/csrf)[ Packagist](https://packagist.org/packages/jimmiw/csrf)[ RSS](/packages/jimmiw-csrf/feed)WikiDiscussions main Synced 1mo ago

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

CSRF token handling for vanilla php systems
===========================================

[](#csrf-token-handling-for-vanilla-php-systems)

This package will make it easy for you to handle CSRF tokens in forms, for systems that might not use fancy frameworks etc.

The idea itself comes from here:

Getting started
===============

[](#getting-started)

The package is availabe here on Github and on Packagist

-
-

Installing
----------

[](#installing)

To use the system, simply require it using composer:

```
composer require jimmiw/csrf

```

Using the component
-------------------

[](#using-the-component)

Using the component is pretty easy, simply construct the class and call generateToken.

```
use Westsworld\CSRF\Generator;

// you can add a custom session handler, when creating the token handler in the construct method.
$tokenHandler = new Generator();
// the generated token is stored in the session
$token = $tokenHandler->generateToken();
