私はphpページ(index.php)を持っています。ユーザー名とパスワードを確認した後、セッションが設定され($ _SESSION ['expire'])、30分後に期限切れになり、設定が解除されます(ログインボタンを押してから30分)そして再び index.php にリダイレクトします:
header('location:index.php');
確認後、その項目の 1 つが ContentManager.php であるメニューがインデックス ページに表示されます。以下に示すように、この項目をクリックすると、データベースに接続され、contentmanager.php に入ります。
switch($_REQUEST['action'])
{
case 'ContentManager' :
include('model/content.php');
$contents = getContent($conn);
include('view/contentmanager.php');
break;
}
私が持っているContentManger.phpで:
<?php
//if the session is not unset and expired yet
if ( isset($_SESSION['expire']) && ($now<= $_SESSION['expire']))
{
?>
do sth...
<?php
}
else
{
//unset the session and redirect to index.php again
unset($_SESSION['expire']);
session_destroy();
header('location:../index.php');}
?>
これは正常に機能しますが、問題は、30分経過した後、「ContentManager」を2回押してindex.phpにリダイレクトする必要があることです.1回だけ押すと、空白のページが表示されます. しかし、ページを 2 回目に更新すると、再度ログイン ページ (index.php) にリダイレクトされます。
私を助けてください...