blessing-skin-server/includes/session.inc.php
2016-02-06 23:30:32 +08:00

25 lines
680 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: prpr
* @Date: 2016-02-06 23:18:49
* @Last Modified by: prpr
* @Last Modified time: 2016-02-06 23:27:48
*/
session_start();
$dir = dirname(dirname(__FILE__));
require "$dir/includes/autoload.inc.php";
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=非法访问,请先登录。');
}