<?php
 session_start();
if(isset($_COOKIE["id"]))

     $cookie_id = $_COOKIE["id"];
		 else {
		 	$cookie_id = "";
		 }
 ?>

<html>
<head>
	 <meta charset="utf-8">
	 <meta name="viewport" content="width=device-width, initial-scale=1.0">
	 <title>로그인</title>
 </head>
 <body>
	 <?php
	 if(isset($_SESSION["id"]))
	 {
	 	?>
     <?=$_SESSION["name"]?> 님 환영합니다.
		 <a href="logout.php">로그아웃</a>
		    <?php
			}
	 		 else {
	  ?>
			 	   <form method="post" action="login.php">
				 <table border="1">
					 <tr><td>
    				<input type="text" placeholder="아이디" name="id" value="<?=$cookie_id?>" required>
					</td>
					<td rowspan="2">
						<input type="submit" value="로그인" >
					</td>
				</tr>
				<tr>
					 <td>
						<input type="password" name="pw" required >
					</td>
				</tr>
</table> <br>
<input type="checkbox" name="id_ck"> ID저장
<a href="../week07/memberform.php">회원가입</a>

</form>
<?php
   }
 ?>
	</body>
		</html>
