blessing-skin-server/app/Controllers/HomeController.php

31 lines
823 B
PHP
Raw Normal View History

2016-07-21 22:01:57 +08:00
<?php
namespace App\Controllers;
use App\Models\User;
class HomeController extends BaseController
{
public function index()
{
2016-07-27 22:31:49 +08:00
if (isset($_COOKIE['email']) && isset($_COOKIE['token'])) {
$user = new User($_COOKIE['email']);
if ($_COOKIE['token'] == $user->getToken() && $user->getPermission() != "-1") {
$_SESSION['email'] = $_COOKIE['email'];
$_SESSION['token'] = $_COOKIE['token'];
} else {
// delete cookies
setcookie("email", "", time() - 3600, '/');
setcookie("token", "", time() - 3600, '/');
}
}
2016-08-16 13:27:06 +08:00
$user = isset($_SESSION['email']) ? new User(0, ['email' => $_SESSION['email']]) : null;
2016-07-27 22:31:49 +08:00
echo \View::make('index')->with('user', $user);
2016-07-21 22:01:57 +08:00
}
}