phpmyadmin/libraries/session.lib.php
Maurício Meneghini Fauth ca910e8de8 Move classes to PhpMyAdmin namespace
- Move Table to PhpMyAdmin namespace
- Move Template to PhpMyAdmin namespace
- Move ThemeManager to PhpMyAdmin namespace
- Move Theme to PhpMyAdmin namespace
- Move Tracker to PhpMyAdmin namespace
- Move Transformations to PhpMyAdmin namespace
- Move TypesMySQL to PhpMyAdmin namespace
- Move Types to PhpMyAdmin namespace
- Move Util to PhpMyAdmin namespace
- Move VersionInformation to PhpMyAdmin namespace
- Move Url to PhpMyAdmin namespace

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
2017-07-08 10:54:21 -03:00

48 lines
1012 B
PHP

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* session library
*
* @package PhpMyAdmin
*/
use PhpMyAdmin\Core;
use PhpMyAdmin\Util;
/**
* tries to secure session from hijacking and fixation
* should be called before login and after successful login
* (only required if sensitive information stored in session)
*
* @return void
*/
function PMA_secureSession()
{
// prevent session fixation and XSS
if (session_status() === PHP_SESSION_ACTIVE && ! defined('TESTSUITE')) {
session_regenerate_id(true);
}
PMA_generateToken();
}
/**
* Generates PMA_token session variable.
*
* @return void
*/
function PMA_generateToken()
{
$_SESSION[' PMA_token '] = Util::generateRandom(16);
/**
* Check if token is properly generated (the generation can fail, for example
* due to missing /dev/random for openssl).
*/
if (empty($_SESSION[' PMA_token '])) {
Core::fatalError(
'Failed to generate random CSRF token!'
);
}
}