質問編集履歴
2
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,6 +11,82 @@
|
|
11
11
|
ご助言いただきたく宜しくお願いいたします。
|
12
12
|
|
13
13
|
```php
|
14
|
+
|
15
|
+
<?php
|
16
|
+
|
17
|
+
session_start();
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
if (!isset($_SESSION["NAME"])) {
|
22
|
+
|
23
|
+
header("Location: 403.php");
|
24
|
+
|
25
|
+
exit;
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
try {
|
32
|
+
|
33
|
+
$db = new PDO('mysql:host=〇〇;dbname=〇〇;charset=utf8', '〇〇’, '〇〇');
|
34
|
+
|
35
|
+
$stt = $db->prepare('SELECT sdate FROM userdata');
|
36
|
+
|
37
|
+
$stt->execute();
|
38
|
+
|
39
|
+
} catch(PDOException $e) {
|
40
|
+
|
41
|
+
die('エラーメッセージ:'.$e->getmessage());
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
?>
|
48
|
+
|
49
|
+
<!doctype html>
|
50
|
+
|
51
|
+
<html>
|
52
|
+
|
53
|
+
<head>
|
54
|
+
|
55
|
+
<meta charset="UTF-8">
|
56
|
+
|
57
|
+
<title>メイン</title>
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<link rel="stylesheet" href="test.css">
|
62
|
+
|
63
|
+
</head>
|
64
|
+
|
65
|
+
<body>
|
66
|
+
|
67
|
+
<div class="parent">
|
68
|
+
|
69
|
+
<h1></h1>
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<?php
|
76
|
+
|
77
|
+
echo('最終ログイン時間'); while ($row = $stt->fetch())
|
78
|
+
|
79
|
+
echo $row["sdate"];?>
|
80
|
+
|
81
|
+
<div class="kakko" >
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<form method="POST" action="session.php"> <input type="submit" id="logout" name="logout" value="logout" />
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
14
90
|
|
15
91
|
<?php
|
16
92
|
|
@@ -44,6 +120,28 @@
|
|
44
120
|
|
45
121
|
|
46
122
|
|
123
|
+
</div>
|
124
|
+
|
125
|
+
<p>※当サイトは3分間で強制ログアウトされます。</p>
|
126
|
+
|
127
|
+
</div>
|
128
|
+
|
129
|
+
<ul>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
</body>
|
136
|
+
|
137
|
+
</form>
|
138
|
+
|
139
|
+
</html>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
47
145
|
|
48
146
|
|
49
147
|
```
|
1
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,11 +20,11 @@
|
|
20
20
|
|
21
21
|
$_SESSION = array();
|
22
22
|
|
23
|
-
|
23
|
+
if (isset($_COOKIE[session_name()])) {
|
24
24
|
|
25
|
-
|
25
|
+
setcookie(session_name(), '', time()-42000, '/');
|
26
26
|
|
27
|
-
|
27
|
+
}
|
28
28
|
|
29
29
|
session_destroy();
|
30
30
|
|
@@ -44,4 +44,6 @@
|
|
44
44
|
|
45
45
|
|
46
46
|
|
47
|
+
|
48
|
+
|
47
49
|
```
|