零依赖跨站请求伪造保护

0.0.1 2022-02-21 20:04 UTC

This package is auto-updated.

Last update: 2024-09-22 02:01:41 UTC


README

Unit Tests

treehousetim/xcsrf

一个库,用于启用简单的跨站请求伪造拦截

安装

composer require treehousetim/xcsrf

使用

<?php namespace App\Controllers;

use treehousetim\xcsrf\xcsrf;

if( $_POST )
{
	xcsrf::getInstance()->protect();
	// process POST request here.
}

echo '<form>';
echo '<input type="hidden" value="' . xcsrf::getInstance()->getCode() . '"></input>';
echo '<input type="submit" value="Submit"></input>';
echo '</form>';