SproutCMS

This is the code documentation for the SproutCMS project

class Csrf

Protection against Cross Site Request Forgery (CSRF) attacks

Extending this class

<?php
/**
* New class description goes here
* 
* @author Your Name, 2024-11-25
**/
class NewClassName extends Csrf {
    
    /**
    * Gets the CSRF token in the postdata.
    * Checks that it is valid.
    * Returns TRUE on success and FALSE on failure
    **/
    public function check () {
        // Method code goes here
    }
    
    /**
    * Checks the CSRF token
    * If it fails, redirect the user to the home page, and report an error
    **/
    public function checkOrDie () {
        // Method code goes here
    }
    
    /**
    * Fetches the secret token value
    * 
    * This is intended for use on JavaScript requests that require CSRF protection.
    * Note that it is important that this value isn't placed in GET parameters, as this
    * may result in the value being leaked through logging or other methods.
    **/
    public function getTokenValue () {
        // Method code goes here
    }
    
    /**
    * Initialises the PHP session and, if not present, generates a CSRF secret for the session
    **/
    protected function initialiseSession () {
        // Method code goes here
    }
    
    /**
    * Generates a CSRF hidden form field
    **/
    public function token () {
        // Method code goes here
    }
    
}
?>