PHP Classes

File: server_FormToken.php

Recommend this page to a friend!
  Classes of Ray Paseur   Lightweight PHP Form Token Validation   server_FormToken.php   Download  
File: server_FormToken.php
Role: Application script
Content type: text/plain
Description: Server-side token generator
Class: Lightweight PHP Form Token Validation
Generate and validate form tokens served via AJAX
Author: By
Last change:
Date: 5 years ago
Size: 500 bytes
 

Contents

Class file image Download
<?php // server_FormToken.php
/**
 * A server side script that responds to an AJAX request
 * This script gets a form token object and encodes it into a JSON string
 * It stores the JSON string in the PHP session and echos it to the client
 */
error_reporting(E_ALL);
require_once(
'class_FormToken.php');
session_start();


// Get, save, and return a new form token object
$token = FormToken::get();
$_SESSION[$token->name] = json_encode($token);
session_write_close();
echo
$_SESSION[$token->name];