===エラーメッセージ===
Notice: Object of class DateTime could not be converted to int in /Applications/XAMPP/xamppfiles/htdocs/Task4/a.php on line 48
Notice: Object of class DateTime could not be converted to int in /Applications/XAMPP/xamppfiles/htdocs/Task4/a.php on line 48
==============
のように、エラーが表示されておりますが、他の部分も自信が全くありません。
行いたいことは、現在時刻とページ最後に操作した時間を比較し、未操作時間が10分以上立っていればログアウトする。という仕様です。
どうかよろしくお願い致します。
php
1<?php 2 //ログイン時間 3 date_default_timezone_set('Asia/Tokyo'); 4 $now_date=date('Y-m-d H:i:s'); 5 $dt1 = new DateTime($now_date); 6 7 //自動ログアウト 始まり 8 if(!isset($_SESSION['OK'])){ 9 header("Location:index.php"); 10 exit(); 11 }else{ 12 $last_operation = $now_date; 13 $dt2 = new DateTime($last_operation); 14 15 if(($dt1 - $dt2) > 60 * 10){ //48行目 16 session_destroy(); 17 header("Location:index.php"); 18 exit(); 19 }else{ 20 $last_operation = date('Y-m-d H:i:s'); 21 } 22 } 23 //自動ログアウト 終わり 24 25 ?> 26
回答1件
あなたの回答
tips
プレビュー