我正在使用来自http://tutorialzine.com/2009/10/cool-login-system-php-jquery/的 PHP 登录系统只是为了给你一个快速的概述,我相信本教程在下面设置了变量方式:
<?php
define('INCLUDE_CHECK',true);
require 'connect.php';
require 'functions.php';
// Those two files can be included only if INCLUDE_CHECK is defined
session_name('tzLogin');
// Starting the session
session_set_cookie_params(1*7*24*60*60);
// Making the cookie live for 1 weeks
session_start();
if($_SESSION['id'] && !isset($_COOKIE['tzRemember']) && !$_SESSION['rememberMe'])
..........
到目前为止一切顺利,除了我无法将会话变量从主登录页面转移到后续页面(包含受限内容)。这是我打算放在每个受限内容页面开头的基本代码
<?php
session_name('tzLogin');
session_set_cookie_params(1*7*24*60*60);
session_start();
if($_SESSION['id']) <-- I believe I need more code here (incldue the cookie)
{
//If all is well, I want the script to proceed and display the HTML content below.
}
else
{
header("Location: MainLogin.html");
or die;
//redirects user to the main login page.
}
?>
正如你所看到的,我是一个完全的新手,但任何帮助将不胜感激。截至目前,即使我正确登录,我的受限内容页面也会不断被重定向到主页。因此我怀疑 SESSION 状态没有被延续。再次感谢!