使用PHP的會話我一直在使用這種代碼在我的網頁一個問題:PHP:「該網站重定向過多」時,隨着時間的推移
代碼到期會議
<?php
session_start();
if(!isset($_SESSION['clientmacs'])) {
header('Location: index.php');
} else {
if(time() - $_SESSION['timeLogin'] > 1800) {
header('Location: include/logout.php');
}
$userclient = $_SESSION['clientmacs'];
?>
<html>
HTML CODE
</html>
<?php
}
?>
但如果我使用此代碼的問題消失,頁面正常工作:
代碼而不終止會話
<?php
session_start();
if(!isset($_SESSION['clientmacs'])) {
header('Location: index.php');
} else {
$userclient = $_SESSION['client'];;
?>
<html>
HTML CODE
</html>
<?php
}
?>
錯誤谷歌瀏覽器:
This webpage has a redirect loop
Http://localhost/mac/index.php The website has too many redirects. The incidence may be
resolved by deleting the cookies from this site or allowing third party cookies. If
that fails, the incidence may be related to a bug in the server configuration, not the
computer.
適合我和@Ibu的回答! – SoldierCorp 2012-07-11 21:35:12