blessing-skin-server/libraries/session.inc.php
2016-03-26 18:50:47 +08:00

26 lines
723 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* @Author: printempw
* @Date: 2016-02-06 23:18:49
* @Last Modified by: printempw
* @Last Modified time: 2016-03-26 18:47:49
*/
session_start();
$dir = dirname(dirname(__FILE__));
require "$dir/libraries/autoloader.php";
Database\Database::checkConfig();
if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
$_SESSION['uname'] = $_COOKIE['uname'];
$_SESSION['token'] = $_COOKIE['token'];
}
if (isset($_SESSION['uname'])) {
$user = new User($_SESSION['uname']);
if ($_SESSION['token'] != $user->getToken()) {
header('Location: ../index.php?msg=无效的 token请重新登录。');
}
} else {
header('Location: ../index.php?msg=非法访问,请先登录。');
}