セッションが内部に設定されているindex.phpページがあります($ _SESSION ['expire'])。このセッションは30分後に設定を解除し、index.phpにリダイレクトする必要があります(ユーザーを再度確認するため)。
私のindex.phpコードの一部:
<?php
session_start();
//if user name and password are valid do the following:
$_SESSION['start'] = time();
$_SESSION['expire'] = $_SESSION['start'] + (30 * 60) ;
?>
<a href="index.php?action=ContentManager">
content
</a>
<?php
if(isset($_REQUEST['action']))
{
//if the expiration time has not reached yet do the following
$now=time();
if (isset($_SESSION['expire']) && ($now<= $_SESSION['expire']))
{
switch($_REQUEST['action'])
{
case 'ContentManager' :
include('model/content.php');
$contents = getContent($conn, ' where 1=1');
include('view/contentmanager.php');
break;
}
}
else if($now > $_SESSION['expire'])
{
unset($_SESSION['expire']);
session_destroy();
header('location:index.php');
exit();
}
}
?>
問題は、30分後にcontentmanagerリンクをクリックすると、次のURLの空のページにリダイレクトされることです:index.php?action = contentmanager
また、ページを再度更新した場合にのみ、index.php自体にリダイレクトされ、ログインフォームが表示されます。
簡単に言うと、正しいページにリダイレクトするには、ページを2回更新する必要があります。
前もって感謝します