php:只有获取参数才能执行页面

时间:2016-02-29 02:37:23

标签: php

我的 mainpage.php 是在用户登录 login.html 后打开的。

登录步骤:l ogin.html - > checkLogin.php - > mainpage.php

现在,我在 checklogin.php 中使用scala> data.endsWith("abc" + util.Properties.lineSeparator) res1: Boolean = true ,在 mainpage.php 中使用$_SESSION['user_id'] = $user_id。但是,只有在获取$user_id = $_SESSION['user_id']时才能执行 mainpage.php 。如果没有,它会显示一个"请再次登录!"消息。

1 个答案:

答案 0 :(得分:0)

检查它是否存在:

// mainpage.php
if ( ! isset($_SESSION['user_id'])) {
    die('pleases login again !');
}