<?php



if (isset($_POST['user_id'])) {
// Not logged in :(

    setcookie("secondcookie[id]",$_POST['user_id'], time() * 7200, "/"); // Expiring after 2 hours
    setcookie("secondcookie[password]", $_POST['user_pass'], time() * 7200, "/");


    //when to see if cookies is set or not

echo $_COOKIE["secondcookie"]["id"]; 


    //header("Location:verification_data.php"); 


}

if (isset($_COOKIE['secondcookie']['id'])){
 // Already Logged in go to page 3
 header("Location:page3.php"); 
}

 ?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MASTERS THESIS PROJECT</title>
</head>

<body  >
<form name="login_form" method="post" >

<center>
<img src="img1.jpg" width="1300"  />

<br />
<br />
<br />
<br />

<table border="4" bgcolor="#CCCCCC">
<tr><th colspan="2">MEMBER LOGIN</th></tr>
<tr>
<td>USER ID :</td> <td><input type="text" name="user_id" id="user_id"  /></td>
</tr>
<tr>
<td>USER PASSWORD :</td><td><input type="password" name="user_pass" id="user_pass"   /></td>
</tr>

<tr><td colspan="2" align="center"><input type="submit" value="login" name="login"  /><input type="reset" value="reset" name="reset"  /> </td></tr>
<tr><td colspan="2" align="center"><a href="page5.php">create a new account here</a></td></tr>

</table>
</center>
</form>
</body>
</html>

The problem should be with the time you've set..

If you want the cookie to expire in 2 hours you should set it to time() + 7200, instead of time() * 7200..

It should be the time() plus the [no. of seconds]..

thanks but it still not working

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.